Package io.micronaut.http.client.netty
Interface NettyClientCustomizer
-
public interface NettyClientCustomizerInterface implemented by users to hook into the pipeline setup of the netty HTTP client.
The internal pipeline of our HTTP client is by necessity complex and unstable across versions. While we strive to retain compatibility, please do not make too many assumptions about the Micronaut HTTP client pipeline structure when implementing this interface.
Implementations of this interface are scoped to different lifetimes. The root customizers can be added through theNettyClientCustomizer.Registry, and live while the context is running. Customizers with narrower scope are created from the root customizers throughspecializationwhen new netty channels are created by the client, e.g. when a new request is made. These specialized customizers will then receive notifications when a certain step in the pipeline setup is reached, so they can do their own customizations on the channel and the channel pipeline they received in the specialization step.- Since:
- 3.6.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classNettyClientCustomizer.ChannelRoleEnum to describe the role of the channel passed tospecializeForChannel(Channel, ChannelRole).static interfaceNettyClientCustomizer.RegistryInterface implemented by the HTTP client registry to register customizers.
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default voidonInitialPipelineBuilt()Called when the initial connection pipeline has been built, before any incoming data has been processed.default voidonRequestPipelineBuilt()Called when the "final" request pipeline has been built for processing http requests.default voidonStreamPipelineBuilt()Called when the stream pipeline has been built, after any TLS or HTTP upgrade handshake.default NettyClientCustomizerspecializeForChannel(io.netty.channel.Channel channel, NettyClientCustomizer.ChannelRole role)
-
-
-
Method Detail
-
specializeForChannel
@NonNull default NettyClientCustomizer specializeForChannel(@NonNull io.netty.channel.Channel channel, @NonNull NettyClientCustomizer.ChannelRole role)
- Parameters:
channel- The new channel to specialize for.role- The role (or scope) of the channel.- Returns:
- The new customizer, or
thisif no specialization needs to take place.
-
onInitialPipelineBuilt
default void onInitialPipelineBuilt()
Called when the initial connection pipeline has been built, before any incoming data has been processed.
-
onStreamPipelineBuilt
default void onStreamPipelineBuilt()
Called when the stream pipeline has been built, after any TLS or HTTP upgrade handshake.
-
onRequestPipelineBuilt
default void onRequestPipelineBuilt()
Called when the "final" request pipeline has been built for processing http requests. This is called for each request, potentially multiple times for the same connection if the connection is pooled. In the future, for HTTP2, this may use a new channel for each request stream.
-
-