ProviderHttpClients

The HTTP clients of a model provider that accepts connect-timeout and read-timeout under its own prefix, falling back to embabel.agent.platform.http-client.* for whichever it leaves unset.

A provider normally clones the shared aiModelRestClientBuilder / aiModelWebClientBuilder beans. Those carry the http-client timeouts and cannot be changed, so a provider that sets a timeout of its own (ownsTransport) replaces their transport with its own client. Anything else customised on that transport, such as a proxy or TLS, then does not apply to the provider.

The replacement is reactor-netty, configured as NettyClientAutoConfiguration configures the shared client: read is netty's response timeout, which bounds each wait between reads, so a stream that stalls mid-body fails too. When the application opted out of reactor-netty (reactorNetty false) it is the JDK client instead, whose read bounds only the wait for response headers.

Needs spring-webflux and reactor-netty-http on the classpath, which this module declares as optional.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

How long to wait to connect: the provider's timeout, else the http-client one.

Link copied to clipboard

Whether the provider set a timeout of its own, and so uses its own transport.

Link copied to clipboard

Whether that transport is reactor-netty rather than the JDK client.

Link copied to clipboard

How long to wait for a response: the provider's timeout, else the http-client one.

Functions

Link copied to clipboard
fun connector(): <Error class: unknown class>

The connector for streamed calls that webClientBuilder installs when the provider ownsTransport. Public so a provider's tests can check which transport it chose.

Link copied to clipboard
fun requestFactory(): <Error class: unknown class>

The request factory for blocking calls that restClientBuilder installs when the provider ownsTransport. Public so a provider's tests can check which transport it chose.

Link copied to clipboard
fun restClientBuilder(shared: <Error class: unknown class><<Error class: unknown class>>): <Error class: unknown class>

A clone of shared, with this provider's transport when it ownsTransport. When no shared builder is available, a JDK-backed one carrying connect and read, so a slow response is not aborted at the ~10s default a bare reactor-netty request factory would impose.

Link copied to clipboard
fun webClientBuilder(shared: <Error class: unknown class><<Error class: unknown class>>): <Error class: unknown class>

A clone of shared, with this provider's transport when it ownsTransport. Without a shared builder, a builder whose connector carries the resolved timeouts, as restClientBuilder does for blocking calls, so a streamed call is bounded by the http-client values too.