@Factory @Internal public class DefaultNettyHttpClientRegistry extends Object implements AutoCloseable, HttpClientRegistry<HttpClient>, SseClientRegistry<SseClient>, StreamingHttpClientRegistry<StreamingHttpClient>, WebSocketClientRegistry<WebSocketClient>, ProxyHttpClientRegistry<ProxyHttpClient>, ChannelPipelineCustomizer
HttpClient
interface based on Netty.HANDLER_ACCESS_LOGGER, HANDLER_CONNECT_TTL, HANDLER_FLOW_CONTROL, HANDLER_HTTP_AGGREGATOR, HANDLER_HTTP_CHUNK, HANDLER_HTTP_CLIENT_CODEC, HANDLER_HTTP_CLIENT_INIT, HANDLER_HTTP_COMPRESSOR, HANDLER_HTTP_DECODER, HANDLER_HTTP_DECOMPRESSOR, HANDLER_HTTP_KEEP_ALIVE, HANDLER_HTTP_PROXY, HANDLER_HTTP_SERVER_CODEC, HANDLER_HTTP_STREAM, HANDLER_HTTP_TO_HTTPS_REDIRECT, HANDLER_HTTP2_CONNECTION, HANDLER_HTTP2_PROTOCOL_NEGOTIATOR, HANDLER_HTTP2_SETTINGS, HANDLER_HTTP2_UPGRADE_REQUEST, HANDLER_IDLE_STATE, HANDLER_MICRONAUT_FULL_HTTP_RESPONSE, HANDLER_MICRONAUT_HTTP_RESPONSE_FULL, HANDLER_MICRONAUT_HTTP_RESPONSE_STREAM, HANDLER_MICRONAUT_INBOUND, HANDLER_MICRONAUT_SSE_CONTENT, HANDLER_MICRONAUT_SSE_EVENT_STREAM, HANDLER_MICRONAUT_WEBSOCKET_CLIENT, HANDLER_READ_TIMEOUT, HANDLER_SOCKS_5_PROXY, HANDLER_SSL, HANDLER_WEBSOCKET_UPGRADE
Constructor and Description |
---|
DefaultNettyHttpClientRegistry(HttpClientConfiguration defaultHttpClientConfiguration,
HttpClientFilterResolver httpClientFilterResolver,
LoadBalancerResolver loadBalancerResolver,
NettyClientSslBuilder nettyClientSslBuilder,
ThreadFactory threadFactory,
MediaTypeCodecRegistry codecRegistry,
EventLoopGroupRegistry eventLoopGroupRegistry,
EventLoopGroupFactory eventLoopGroupFactory,
BeanContext beanContext,
List<InvocationInstrumenterFactory> invocationInstrumenterFactories,
JsonMapper jsonMapper)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
disposeClient(AnnotationMetadata annotationMetadata)
Dispose of the client defined by the given metadata.
|
void |
doOnConnect(ChannelPipelineListener listener)
A hook to customize the pipeline upon establishing a connection.
|
DefaultHttpClient |
getClient(AnnotationMetadata metadata)
Return the client for the given annotation metadata.
|
HttpClient |
getClient(HttpVersion httpVersion,
String clientId,
String path)
Return the client for the client ID and path.
|
DefaultHttpClient |
getProxyHttpClient(AnnotationMetadata metadata)
Return the client for the given annotation metadata.
|
DefaultHttpClient |
getSseClient(AnnotationMetadata metadata)
Return the client for the given annotation metadata.
|
DefaultHttpClient |
getStreamingHttpClient(AnnotationMetadata metadata)
Return the client for the given annotation metadata.
|
DefaultHttpClient |
getWebSocketClient(AnnotationMetadata metadata)
Return the client for the given annotation metadata.
|
protected DefaultHttpClient |
httpClient(InjectionPoint<?> injectionPoint,
LoadBalancer loadBalancer,
HttpClientConfiguration configuration,
BeanContext beanContext)
Creates a new
HttpClient for the given injection point. |
boolean |
isClientChannel() |
HttpClient |
resolveClient(InjectionPoint<?> injectionPoint,
LoadBalancer loadBalancer,
HttpClientConfiguration configuration,
BeanContext beanContext)
Resolves a
HttpClient for the given injection point. |
ProxyHttpClient |
resolveProxyHttpClient(InjectionPoint<?> injectionPoint,
LoadBalancer loadBalancer,
HttpClientConfiguration configuration,
BeanContext beanContext)
Resolves a
ProxyHttpClient for the given injection point. |
SseClient |
resolveSseClient(InjectionPoint<?> injectionPoint,
LoadBalancer loadBalancer,
HttpClientConfiguration configuration,
BeanContext beanContext)
Resolves a
SseClient for the given injection point. |
StreamingHttpClient |
resolveStreamingHttpClient(InjectionPoint<?> injectionPoint,
LoadBalancer loadBalancer,
HttpClientConfiguration configuration,
BeanContext beanContext)
Resolves a
StreamingHttpClient for the given injection point. |
WebSocketClient |
resolveWebSocketClient(InjectionPoint<?> injectionPoint,
LoadBalancer loadBalancer,
HttpClientConfiguration configuration,
BeanContext beanContext)
Resolves a
WebSocketClient for the given injection point. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDefaultClient
getDefaultSseClient
getDefaultStreamingHttpClient
getDefaultWebSocketClient
getDefaultProxyHttpClient
isServerChannel
public DefaultNettyHttpClientRegistry(HttpClientConfiguration defaultHttpClientConfiguration, HttpClientFilterResolver httpClientFilterResolver, LoadBalancerResolver loadBalancerResolver, NettyClientSslBuilder nettyClientSslBuilder, ThreadFactory threadFactory, MediaTypeCodecRegistry codecRegistry, EventLoopGroupRegistry eventLoopGroupRegistry, EventLoopGroupFactory eventLoopGroupFactory, BeanContext beanContext, List<InvocationInstrumenterFactory> invocationInstrumenterFactories, JsonMapper jsonMapper)
defaultHttpClientConfiguration
- The default HTTP client configurationhttpClientFilterResolver
- The HTTP client filter resolverloadBalancerResolver
- The load balancer resolvernettyClientSslBuilder
- The client SSL builderthreadFactory
- The thread factorycodecRegistry
- The codec registryeventLoopGroupRegistry
- The event loop group registryeventLoopGroupFactory
- The event loop group factorybeanContext
- The bean contextinvocationInstrumenterFactories
- The invocation instrumenter factoriesjsonMapper
- JSON Mapper@NonNull public HttpClient getClient(HttpVersion httpVersion, @NonNull String clientId, @Nullable String path)
HttpClientRegistry
getClient
in interface HttpClientRegistry<HttpClient>
httpVersion
- The HTTP versionclientId
- The client IDpath
- The path (Optional)@NonNull public DefaultHttpClient getClient(@NonNull AnnotationMetadata metadata)
HttpClientRegistry
getClient
in interface HttpClientRegistry<HttpClient>
metadata
- The annotation metadata.@NonNull public DefaultHttpClient getSseClient(@NonNull AnnotationMetadata metadata)
SseClientRegistry
getSseClient
in interface SseClientRegistry<SseClient>
metadata
- The annotation metadata.@NonNull public DefaultHttpClient getStreamingHttpClient(@NonNull AnnotationMetadata metadata)
StreamingHttpClientRegistry
getStreamingHttpClient
in interface StreamingHttpClientRegistry<StreamingHttpClient>
metadata
- The annotation metadata.@NonNull public DefaultHttpClient getProxyHttpClient(@NonNull AnnotationMetadata metadata)
ProxyHttpClientRegistry
getProxyHttpClient
in interface ProxyHttpClientRegistry<ProxyHttpClient>
metadata
- The annotation metadata.@NonNull public DefaultHttpClient getWebSocketClient(@NonNull AnnotationMetadata metadata)
WebSocketClientRegistry
getWebSocketClient
in interface WebSocketClientRegistry<WebSocketClient>
metadata
- The annotation metadata.@PreDestroy public void close()
close
in interface AutoCloseable
public void disposeClient(AnnotationMetadata annotationMetadata)
HttpClientRegistry
disposeClient
in interface HttpClientRegistry<HttpClient>
disposeClient
in interface ProxyHttpClientRegistry<ProxyHttpClient>
disposeClient
in interface SseClientRegistry<SseClient>
disposeClient
in interface StreamingHttpClientRegistry<StreamingHttpClient>
disposeClient
in interface WebSocketClientRegistry<WebSocketClient>
annotationMetadata
- The annotation metadata@Bean @Primary protected DefaultHttpClient httpClient(@Nullable InjectionPoint<?> injectionPoint, @Parameter @Nullable LoadBalancer loadBalancer, @Parameter @Nullable HttpClientConfiguration configuration, BeanContext beanContext)
HttpClient
for the given injection point.injectionPoint
- The injection pointloadBalancer
- The load balancer to use (Optional)configuration
- The configuration (Optional)beanContext
- The bean context to use@NonNull public HttpClient resolveClient(@Nullable InjectionPoint<?> injectionPoint, @Nullable LoadBalancer loadBalancer, @Nullable HttpClientConfiguration configuration, @NonNull BeanContext beanContext)
HttpClientRegistry
HttpClient
for the given injection point.resolveClient
in interface HttpClientRegistry<HttpClient>
injectionPoint
- The injection pointloadBalancer
- The load balancer to use (Optional)configuration
- The configuration (Optional)beanContext
- The bean context to use@NonNull public ProxyHttpClient resolveProxyHttpClient(@Nullable InjectionPoint<?> injectionPoint, @Nullable LoadBalancer loadBalancer, @Nullable HttpClientConfiguration configuration, @NonNull BeanContext beanContext)
ProxyHttpClientRegistry
ProxyHttpClient
for the given injection point.resolveProxyHttpClient
in interface ProxyHttpClientRegistry<ProxyHttpClient>
injectionPoint
- The injection pointloadBalancer
- The load balancer to use (Optional)configuration
- The configuration (Optional)beanContext
- The bean context to use@NonNull public SseClient resolveSseClient(@Nullable InjectionPoint<?> injectionPoint, @Nullable LoadBalancer loadBalancer, @Nullable HttpClientConfiguration configuration, @NonNull BeanContext beanContext)
SseClientRegistry
SseClient
for the given injection point.resolveSseClient
in interface SseClientRegistry<SseClient>
injectionPoint
- The injection pointloadBalancer
- The load balancer to use (Optional)configuration
- The configuration (Optional)beanContext
- The bean context to use@NonNull public StreamingHttpClient resolveStreamingHttpClient(@Nullable InjectionPoint<?> injectionPoint, @Nullable LoadBalancer loadBalancer, @Nullable HttpClientConfiguration configuration, @NonNull BeanContext beanContext)
StreamingHttpClientRegistry
StreamingHttpClient
for the given injection point.resolveStreamingHttpClient
in interface StreamingHttpClientRegistry<StreamingHttpClient>
injectionPoint
- The injection pointloadBalancer
- The load balancer to use (Optional)configuration
- The configuration (Optional)beanContext
- The bean context to use@NonNull public WebSocketClient resolveWebSocketClient(@Nullable InjectionPoint<?> injectionPoint, @Nullable LoadBalancer loadBalancer, @Nullable HttpClientConfiguration configuration, @NonNull BeanContext beanContext)
WebSocketClientRegistry
WebSocketClient
for the given injection point.resolveWebSocketClient
in interface WebSocketClientRegistry<WebSocketClient>
injectionPoint
- The injection pointloadBalancer
- The load balancer to use (Optional)configuration
- The configuration (Optional)beanContext
- The bean context to usepublic boolean isClientChannel()
isClientChannel
in interface ChannelPipelineCustomizer
public void doOnConnect(@NonNull ChannelPipelineListener listener)
ChannelPipelineCustomizer
doOnConnect
in interface ChannelPipelineCustomizer
listener
- The listener The listener.