public static interface NettyNioAsyncHttpClient.Builder extends SdkAsyncHttpClient.Builder<NettyNioAsyncHttpClient.Builder>
NettyNioAsyncHttpClient.builder()
to configure and construct
a Netty HTTP client.Modifier and Type | Method and Description |
---|---|
NettyNioAsyncHttpClient.Builder |
connectionAcquisitionTimeout(Duration connectionAcquisitionTimeout)
The amount of time to wait when acquiring a connection from the pool before giving up and timing out.
|
NettyNioAsyncHttpClient.Builder |
connectionMaxIdleTime(Duration maxIdleConnectionTimeout)
Configure the maximum amount of time that a connection should be allowed to remain open while idle.
|
NettyNioAsyncHttpClient.Builder |
connectionTimeout(Duration timeout)
The amount of time to wait when initially establishing a connection before giving up and timing out.
|
NettyNioAsyncHttpClient.Builder |
connectionTimeToLive(Duration connectionTimeToLive)
The maximum amount of time that a connection should be allowed to remain open, regardless of usage frequency.
|
NettyNioAsyncHttpClient.Builder |
eventLoopGroup(SdkEventLoopGroup eventLoopGroup)
Sets the
SdkEventLoopGroup to use for the Netty HTTP client. |
NettyNioAsyncHttpClient.Builder |
eventLoopGroupBuilder(SdkEventLoopGroup.Builder eventLoopGroupBuilder)
Sets the
SdkEventLoopGroup.Builder which will be used to create the SdkEventLoopGroup for the Netty
HTTP client. |
NettyNioAsyncHttpClient.Builder |
maxConcurrency(Integer maxConcurrency)
Maximum number of allowed concurrent requests.
|
NettyNioAsyncHttpClient.Builder |
maxHttp2Streams(Integer maxHttp2Streams)
Sets the max number of concurrent streams for an HTTP/2 connection.
|
NettyNioAsyncHttpClient.Builder |
maxPendingConnectionAcquires(Integer maxPendingAcquires)
The maximum number of pending acquires allowed.
|
NettyNioAsyncHttpClient.Builder |
protocol(Protocol protocol)
Sets the HTTP protocol to use (i.e.
|
NettyNioAsyncHttpClient.Builder |
putChannelOption(io.netty.channel.ChannelOption channelOption,
Object value)
Configures additional
ChannelOption which will be used to create Netty Http client. |
NettyNioAsyncHttpClient.Builder |
readTimeout(Duration readTimeout)
The amount of time to wait for a read on a socket before an exception is thrown.
|
NettyNioAsyncHttpClient.Builder |
sslProvider(io.netty.handler.ssl.SslProvider sslProvider)
Sets the
SslProvider to be used in the Netty client. |
NettyNioAsyncHttpClient.Builder |
useIdleConnectionReaper(Boolean useConnectionReaper)
Configure whether the idle connections in the connection pool should be closed.
|
NettyNioAsyncHttpClient.Builder |
writeTimeout(Duration writeTimeout)
The amount of time to wait for a write on a socket before an exception is thrown.
|
build, buildWithDefaults
applyMutation
NettyNioAsyncHttpClient.Builder maxConcurrency(Integer maxConcurrency)
If the maximum number of concurrent requests is exceeded they may be queued in the HTTP client (see
maxPendingConnectionAcquires(Integer)
connectionAcquisitionTimeout(Duration)
).
maxConcurrency
- New value for max concurrency.NettyNioAsyncHttpClient.Builder maxPendingConnectionAcquires(Integer maxPendingAcquires)
maxPendingAcquires
- Max number of pending acquiresNettyNioAsyncHttpClient.Builder readTimeout(Duration readTimeout)
Duration.ZERO
to disable.readTimeout
- timeout durationNettyNioAsyncHttpClient.Builder writeTimeout(Duration writeTimeout)
Duration.ZERO
to disable.writeTimeout
- timeout durationNettyNioAsyncHttpClient.Builder connectionTimeout(Duration timeout)
timeout
- the timeout durationNettyNioAsyncHttpClient.Builder connectionAcquisitionTimeout(Duration connectionAcquisitionTimeout)
connectionAcquisitionTimeout
- the timeout durationNettyNioAsyncHttpClient.Builder connectionTimeToLive(Duration connectionTimeToLive)
readTimeout(Duration)
and writeTimeout(Duration)
, this will never close a connection that
is currently in use, so long-lived connections may remain open longer than this time. In particular, an HTTP/2
connection won't be closed as long as there is at least one stream active on the connection.NettyNioAsyncHttpClient.Builder connectionMaxIdleTime(Duration maxIdleConnectionTimeout)
useIdleConnectionReaper(Boolean)
is false.
Unlike readTimeout(Duration)
and writeTimeout(Duration)
, this will never close a connection that
is currently in use, so long-lived connections may remain open longer than this time.NettyNioAsyncHttpClient.Builder useIdleConnectionReaper(Boolean useConnectionReaper)
When enabled, connections left idling for longer than connectionMaxIdleTime(Duration)
will be
closed. This will not close connections currently in use. By default, this is enabled.
NettyNioAsyncHttpClient.Builder eventLoopGroup(SdkEventLoopGroup eventLoopGroup)
SdkEventLoopGroup
to use for the Netty HTTP client. This event loop group may be shared
across multiple HTTP clients for better resource and thread utilization. The preferred way to create
an EventLoopGroup
is by using the SdkEventLoopGroup.builder()
method which will choose the
optimal implementation per the platform.
The EventLoopGroup
MUST be closed by the caller when it is ready to
be disposed. The SDK will not close the EventLoopGroup
when the HTTP client is closed. See
EventExecutorGroup.shutdownGracefully()
to properly close the event loop group.
This configuration method is only recommended when you wish to share an EventLoopGroup
with multiple clients. If you do not need to share the group it is recommended to use
eventLoopGroupBuilder(SdkEventLoopGroup.Builder)
as the SDK will handle its cleanup when
the HTTP client is closed.
eventLoopGroup
- Netty SdkEventLoopGroup
to use.SdkEventLoopGroup
NettyNioAsyncHttpClient.Builder eventLoopGroupBuilder(SdkEventLoopGroup.Builder eventLoopGroupBuilder)
SdkEventLoopGroup.Builder
which will be used to create the SdkEventLoopGroup
for the Netty
HTTP client. This allows for custom configuration of the Netty EventLoopGroup
.
The EventLoopGroup
created by the builder is managed by the SDK and will be shutdown
when the HTTP client is closed.
This is the preferred configuration method when you just want to customize the EventLoopGroup
but not share it across multiple HTTP clients. If you do wish to share an EventLoopGroup
, see
eventLoopGroup(SdkEventLoopGroup)
eventLoopGroupBuilder
- SdkEventLoopGroup.Builder
to use.SdkEventLoopGroup.Builder
NettyNioAsyncHttpClient.Builder protocol(Protocol protocol)
protocol
- Protocol to use.NettyNioAsyncHttpClient.Builder putChannelOption(io.netty.channel.ChannelOption channelOption, Object value)
ChannelOption
which will be used to create Netty Http client. This allows custom
configuration for Netty.
If a ChannelOption
was previously configured, the old value is replaced.
channelOption
- ChannelOption
to setvalue
- See ChannelOption
to find the type of value for each optionNettyNioAsyncHttpClient.Builder maxHttp2Streams(Integer maxHttp2Streams)
Note that this cannot exceed the value of the MAX_CONCURRENT_STREAMS setting returned by the service. If it does the service setting is used instead.
maxHttp2Streams
- Max concurrent HTTP/2 streams per connection.NettyNioAsyncHttpClient.Builder sslProvider(io.netty.handler.ssl.SslProvider sslProvider)
SslProvider
to be used in the Netty client.
If not configured, SslContext.defaultClientProvider()
will be used to determine the SslProvider.
Note that you might need to add other dependencies if not using JDK's default Ssl Provider. See https://netty.io/wiki/requirements-for-4.x.html#transport-security-tls
sslProvider
- the SslProviderCopyright © 2019. All rights reserved.