Nothing Special   »   [go: up one dir, main page]

Skip to main content
Version: 2.x

HTTP implementations

By default the AWS Java SDK uses netty under the hood to make the HTTP client calls. zio-aws defines the http client as a layer (HttpClient) that has to be provided to the AWS configuration layer.

Currently the following implementations can be used:

  • zio-aws-netty contains the default netty implementation packed as a layer
  • zio-aws-akka-http is based on Matthias LΓΌneberg's aws-spi-akka-http library
  • zio-aws-http4s is an implementation on top of http4s
  • zio-aws-crt-http is an implementation on top of the AWS Common Runtime (CRT) HTTP client

Netty​

The default HTTP implementation in the AWS Java SDK is Netty. To use it with the default settings, use the netty.default layer to provide the HttpClient for the AwsConfig layer. It is also possible to customize the NettyNioAsyncHttpClient directly by manipulation it's Builder, by using the netty.customized(customization) layer.

The recommended way for configuration is to use the zio-config support:

def configured(
tlsKeyManagersProvider: Option[TlsKeyManagersProvider] = None,
tlsTrustManagersProvider: Option[TlsTrustManagersProvider] = None
): ZLayer[ZConfig[NettyClientConfig], Throwable, HttpClient]

Everything except the TLS key and trust managers are described by the zio-config provided NettyClientConfig data structure. See the following table for all the options:

Configuration Details​

FieldNameFormatDescriptionSources
all-of

Field Descriptions​

FieldNameFormatDescriptionSources
any-one-of
any-one-of
any-one-of
any-one-of
any-one-of
any-one-of
any-one-of
any-one-of
any-one-of
any-one-of
any-one-of
sslProviderprimitivea text property, The SSL provider to be used
proxyall-ofProxy configuration
http2all-ofHTTP/2 specific options

Field Descriptions​

FieldNameFormatDescriptionSources
maxConcurrencyprimitivean integer property, Maximum number of allowed concurrent requests
primitivea constant property, Maximum number of allowed concurrent requests

Field Descriptions​

FieldNameFormatDescriptionSources
maxPendingConnectionAcquiresprimitivean integer property, The maximum number of pending acquires allowed
primitivea constant property, The maximum number of pending acquires allowed

Field Descriptions​

FieldNameFormatDescriptionSources
readTimeoutprimitivea duration property, The amount of time to wait for a read on a socket
primitivea constant property, The amount of time to wait for a read on a socket

Field Descriptions​

FieldNameFormatDescriptionSources
writeTimeoutprimitivea duration property, The amount of time to wait for a write on a socket
primitivea constant property, The amount of time to wait for a write on a socket

Field Descriptions​

FieldNameFormatDescriptionSources
connectionTimeoutprimitivea duration property, The amount of time to wait when initially establishing a connection before giving up
primitivea constant property, The amount of time to wait when initially establishing a connection before giving up

Field Descriptions​

FieldNameFormatDescriptionSources
connectionAcquisitionTimeoutprimitivea duration property, The amount of time to wait when acquiring a connection from the pool before giving up
primitivea constant property, The amount of time to wait when acquiring a connection from the pool before giving up

Field Descriptions​

FieldNameFormatDescriptionSources
connectionTimeToLiveprimitivea duration property, The maximum amount of time that a connection should be allowed to remain open, regardless of usage frequency
primitivea constant property, The maximum amount of time that a connection should be allowed to remain open, regardless of usage frequency

Field Descriptions​

FieldNameFormatDescriptionSources
connectionMaxIdleTimeprimitivea duration property, Maximum amount of time that a connection should be allowed to remain open while idle
primitivea constant property, Maximum amount of time that a connection should be allowed to remain open while idle

Field Descriptions​

FieldNameFormatDescriptionSources
useIdleConnectionReaperprimitivea boolean property, If true, the idle connections in the pool should be closed
primitivea constant property, If true, the idle connections in the pool should be closed

Field Descriptions​

FieldNameFormatDescriptionSources
protocolprimitivea text property, HTTP/1.1 or HTTP/2 or Dual
primitivea constant property, HTTP/1.1 or HTTP/2 or Dual

Field Descriptions​

FieldNameFormatDescriptionSources
channelOptionsall-ofCustom Netty channel options
primitivea constant property, Custom Netty channel options

channelOptions​

FieldNameFormatDescriptionSources
SO_BROADCASTprimitivea boolean property, Allow transmission of broadcast datagrams
SO_KEEPALIVEprimitivea boolean property, Keep connection alive
SO_SNDBUFprimitivean integer property, The size of the socket send buffer
SO_RCVBUFprimitivean integer property, The size of the socket receive buffer
SO_REUSEADDRprimitivea boolean property, Re-use address
SO_LINGERprimitivean integer property, Linger on close if data is present
IP_TOSprimitivean integer property, The ToS octet in the IP header
IP_MULTICAST_IFprimitivea text property, The network interface's name for IP multicast datagrams
IP_MULTICAST_TTLprimitivean integer property, The time-to-live for IP multicast datagrams
IP_MULTICAST_LOOPprimitivea boolean property, Loopback for IP multicast datagrams
TCP_NODELAYprimitivea boolean property, Disable the Nagle algorithm
CONNECT_TIMEOUT_MILLISprimitivea duration property, Connect timeout
WRITE_SPIN_COUNTprimitivean integer property, Write spin count
ALLOW_HALF_CLOSUREprimitivea boolean property, Allow half closure
AUTO_READprimitivea boolean property, Auto read
AUTO_CLOSEprimitivea boolean property, Auto close
SINGLE_EVENTEXECUTOR_PER_GROUPprimitivea boolean property, Single event executor per group

proxy​

FieldNameFormatDescriptionSources
any-one-of
hostprimitivea text property, Hostname of the proxy
portprimitivean integer property, Port of the proxy
any-one-of

Field Descriptions​

FieldNameFormatDescriptionSources
schemeprimitivea text property, The proxy scheme
primitivea constant property, The proxy scheme

Field Descriptions​

FieldNameFormatDescriptionSources
nonProxyHostslista text property, Hosts that should not be proxied
primitivea constant property, Hosts that should not be proxied

http2​

FieldNameFormatDescriptionSources
maxStreamsprimitivean integer property, Max number of concurrent streams per connection
initialWindowSizeprimitivean integer property, Initial window size of a stream
any-one-of

Field Descriptions​

FieldNameFormatDescriptionSources
healthCheckPingPeriodprimitivea duration property, The period that the Netty client will send PING frames to the remote endpoint
primitivea constant property, The period that the Netty client will send PING frames to the remote endpoint

Akka HTTP​

The Akka HTTP implementation can be chosen by using the akkahttp.client() layer for providing HttpClient to AwsConfig. This implementation uses the standard akka-http settings from the application's Lightbend config, it is not described with zio-config descriptors.

http4s​

Another alternative is the http4s client. To use the default settings, provide the http4s.default layer to AwsConfig. Customization by manipulating the builder is also possible by http4s.customized(customization). And similarly to the Netty client, configuration is also possible via zio-config:

Configuration Details​

FieldNameFormatDescriptionSources
all-of

Field Descriptions​

FieldNameFormatDescriptionSources
any-one-of
any-one-of
any-one-of
any-one-of
any-one-of
any-one-of
any-one-of
any-one-of
any-one-of
any-one-of
any-one-of
any-one-of
any-one-of
any-one-of
any-one-of

Field Descriptions​

FieldNameFormatDescriptionSources
responseHeaderTimeoutprimitivea duration property, Timeout for receiving the header part of the response
primitivea constant property, Timeout for receiving the header part of the response

Field Descriptions​

FieldNameFormatDescriptionSources
idleTimeoutprimitivea duration property, Timeout for client connection staying idle
primitivea constant property, Timeout for client connection staying idle

Field Descriptions​

FieldNameFormatDescriptionSources
requestTimeoutprimitivea duration property, Timeout for the whole request
primitivea constant property, Timeout for the whole request

Field Descriptions​

FieldNameFormatDescriptionSources
connectTimeoutprimitivea duration property, Timeout for connecting to the server
primitivea constant property, Timeout for connecting to the server

Field Descriptions​

FieldNameFormatDescriptionSources
userAgentprimitivea text property, User-Agent header sent by the client
primitivea constant property, User-Agent header sent by the client

Field Descriptions​

FieldNameFormatDescriptionSources
maxTotalConnectionsprimitivean integer property, Maximum number of parallel connections
primitivea constant property, Maximum number of parallel connections

Field Descriptions​

FieldNameFormatDescriptionSources
maxWaitQueueLimitprimitivean integer property, Maximum number of requests in queue
primitivea constant property, Maximum number of requests in queue

Field Descriptions​

FieldNameFormatDescriptionSources
checkEndpointIdentificationprimitivea boolean property, Check https identity
primitivea constant property, Check https identity

Field Descriptions​

FieldNameFormatDescriptionSources
maxResponseLineSizeprimitivean integer property, Maximum line length of headers in response
primitivea constant property, Maximum line length of headers in response

Field Descriptions​

FieldNameFormatDescriptionSources
maxHeaderLengthprimitivean integer property, Maximum total length of the response headers
primitivea constant property, Maximum total length of the response headers

Field Descriptions​

FieldNameFormatDescriptionSources
maxChunkSizeprimitivean integer property, Maximum chunk size
primitivea constant property, Maximum chunk size

Field Descriptions​

FieldNameFormatDescriptionSources
chunkBufferMaxSizeprimitivean integer property, Maximum size of the chunk buffer
primitivea constant property, Maximum size of the chunk buffer

Field Descriptions​

FieldNameFormatDescriptionSources
parserModeprimitivea text property, Parser mode, strict or lenient
primitivea constant property, Parser mode, strict or lenient

Field Descriptions​

FieldNameFormatDescriptionSources
bufferSizeprimitivean integer property, Buffer size
primitivea constant property, Buffer size

Field Descriptions​

FieldNameFormatDescriptionSources
channelOptionsall-ofCollection of socket options
primitivea constant property, Collection of socket options

channelOptions​

FieldNameFormatDescriptionSources
SO_BROADCASTprimitivea boolean property, Allow transmission of broadcast datagrams
SO_KEEPALIVEprimitivea boolean property, Keep connection alive
SO_SNDBUFprimitivean integer property, The size of the socket send buffer
SO_RCVBUFprimitivean integer property, The size of the socket receive buffer
SO_REUSEADDRprimitivea boolean property, Re-use address
SO_LINGERprimitivean integer property, Linger on close if data is present
IP_TOSprimitivean integer property, The ToS octet in the IP header
IP_MULTICAST_IFprimitivea text property, The network interface's name for IP multicast datagrams
IP_MULTICAST_TTLprimitivean integer property, The time-to-live for IP multicast datagrams
IP_MULTICAST_LOOPprimitivea boolean property, Loopback for IP multicast datagrams
TCP_NODELAYprimitivea boolean property, Disable the Nagle algorithm

AWS CRT HTTP​

The new AWS Common Runtime (CRT) HTTP client can be used by providing the crt.default layer for providing HttpClient to AwsConfig.

Configuration Details​

FieldNameFormatDescriptionSources
all-of

Field Descriptions​

FieldNameFormatDescriptionSources
maxConcurrencyprimitivean integer property, The Maximum number of allowed concurrent requests. For HTTP/1.1 this is the same as max connections.
readBufferSizeInBytesprimitivean integer property, Configures the number of unread bytes that can be buffered in the client before we stop reading from the underlying TCP socket and wait for the Subscriber to read more data.
proxyall-ofSets the http proxy configuration to use for this client.
connectionHealthall-ofConfigure the health checks for all connections established by this client.
connectionMaxIdleTimeprimitivea duration property, Configure the maximum amount of time that a connection should be allowed to remain open while idle.
connectionTimeoutprimitivea duration property, The amount of time to wait when initially establishing a connection before giving up and timing out.
tcpKeepAliveall-ofConfigure whether to enable tcpKeepAlive and relevant configuration for all connections established by this client.
postQuantumTlsEnabledprimitivea boolean property, Configure whether to enable a hybrid post-quantum key exchange option for the Transport Layer Security (TLS) network encryption protocol when communicating with services that support Post Quantum TLS. If Post Quantum cipher suites are not supported on the platform, the SDK will use the default TLS cipher suites.

proxy​

FieldNameFormatDescriptionSources
schemeprimitivea text property, The scheme of the proxy
hostprimitivea text property, The host of the proxy
portprimitivean integer property, The port of the proxy
usernameprimitivea text property, The username for the proxy
passwordprimitivea text property, The password for the proxy

connectionHealth​

FieldNameFormatDescriptionSources
minimumThroughputInBpsprimitivean integer property, Sets a throughput threshold for connections. Throughput below this value will be considered unhealthy
minimumThroughputTimeoutprimitivea duration property, Sets how long a connection is allowed to be unhealthy before getting shut down

tcpKeepAlive​

FieldNameFormatDescriptionSources
keepAliveIntervalprimitivea duration property, The number of seconds between TCP keepalive packets being sent to the peer
keepAliveTimeoutprimitivea duration property, The number of seconds to wait for a keepalive response before considering the connection timed out