Package io.micronaut.http.client
Class ServiceHttpClientConfiguration
java.lang.Object
io.micronaut.http.client.HttpClientConfiguration
io.micronaut.http.client.ServiceHttpClientConfiguration
- All Implemented Interfaces:
ClientContextPathProvider
@EachProperty("micronaut.http.services")
public class ServiceHttpClientConfiguration
extends HttpClientConfiguration
implements ClientContextPathProvider
Allows defining HTTP client configurations via the
micronaut.http.services
setting.- Since:
- 1.0
- Author:
- graemerocher
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
The default connection pool configuration.static class
The service HTTP/2 configuration.static class
The default connection pool configuration.static class
The default WebSocket compression configuration.Nested classes/interfaces inherited from class io.micronaut.http.client.HttpClientConfiguration
HttpClientConfiguration.ConnectionPoolConfiguration, HttpClientConfiguration.DnsResolutionMode, HttpClientConfiguration.Http2ClientConfiguration, HttpClientConfiguration.WebSocketCompressionConfiguration
-
Field Summary
Modifier and TypeFieldDescriptionstatic final boolean
The default health check value.static final long
The default health check interval in seconds.static final String
The default health check uri.static final String
Prefix for HTTP Client settings.Fields inherited from class io.micronaut.http.client.HttpClientConfiguration
DEFAULT_ALLOW_BLOCK_EVENT_LOOP, DEFAULT_CONNECTION_POOL_IDLE_TIMEOUT_SECONDS, DEFAULT_DNS_RESOLUTION_MODE, DEFAULT_EXCEPTION_ON_ERROR_STATUS, DEFAULT_FOLLOW_REDIRECTS, DEFAULT_MAX_CONTENT_LENGTH, DEFAULT_READ_IDLE_TIMEOUT_MINUTES, DEFAULT_READ_TIMEOUT_SECONDS, DEFAULT_SHUTDOWN_QUIET_PERIOD_MILLISECONDS, DEFAULT_SHUTDOWN_TIMEOUT_MILLISECONDS
-
Constructor Summary
ConstructorDescriptionServiceHttpClientConfiguration
(String serviceId, @Nullable ServiceHttpClientConfiguration.ServiceConnectionPoolConfiguration connectionPoolConfiguration, @Nullable ServiceHttpClientConfiguration.ServiceSslClientConfiguration sslConfiguration, HttpClientConfiguration defaultHttpClientConfiguration) Deprecated.ServiceHttpClientConfiguration
(String serviceId, @Nullable ServiceHttpClientConfiguration.ServiceConnectionPoolConfiguration connectionPoolConfiguration, @Nullable ServiceHttpClientConfiguration.ServiceSslClientConfiguration sslConfiguration, ApplicationConfiguration applicationConfiguration) Creates a new client configuration for the given service ID.ServiceHttpClientConfiguration
(String serviceId, @Nullable ServiceHttpClientConfiguration.ServiceConnectionPoolConfiguration connectionPoolConfiguration, @Nullable ServiceHttpClientConfiguration.ServiceWebSocketCompressionConfiguration webSocketCompressionConfiguration, @Nullable ServiceHttpClientConfiguration.ServiceSslClientConfiguration sslConfiguration, HttpClientConfiguration defaultHttpClientConfiguration) ServiceHttpClientConfiguration
(String serviceId, @Nullable ServiceHttpClientConfiguration.ServiceConnectionPoolConfiguration connectionPoolConfiguration, @Nullable ServiceHttpClientConfiguration.ServiceWebSocketCompressionConfiguration webSocketCompressionConfiguration, ServiceHttpClientConfiguration.ServiceHttp2ClientConfiguration http2Configuration, @Nullable ServiceHttpClientConfiguration.ServiceSslClientConfiguration sslConfiguration, HttpClientConfiguration defaultHttpClientConfiguration) Creates a new client configuration for the given service ID. -
Method Summary
Modifier and TypeMethodDescriptionObtains the connection pool configuration.The default duration to check health status.The URI to check the service for health status.Obtains the HTTP/2 configuration.getPath()
The context path to use for requests.The service id.getUrls()
The URLs.Obtains the WebSocket compression configuration.boolean
Whether the service health should be checked.void
setHealthCheck
(boolean healthCheck) Sets whether the service health should be checked.void
setHealthCheckInterval
(Duration healthCheckInterval) Sets the default duration to check health status.void
setHealthCheckUri
(String healthCheckUri) Sets the health check URI.void
Sets the context path to use for requests.void
Sets the URL of the service.void
Sets the URIs of the service.Methods inherited from class io.micronaut.http.client.HttpClientConfiguration
getAddressResolverGroupName, getAlpnModes, getChannelOptions, getConnectionPoolIdleTimeout, getConnectTimeout, getConnectTtl, getDefaultCharset, getDnsResolutionMode, getEventLoopGroup, getHttpVersion, getLoggerName, getLogLevel, getMaxContentLength, getNumOfThreads, getPlaintextMode, getProxyAddress, getProxyPassword, getProxySelector, getProxyType, getProxyUsername, getReadIdleTimeout, getReadTimeout, getRequestTimeout, getShutdownQuietPeriod, getShutdownTimeout, getSslConfiguration, getThreadFactory, isAllowBlockEventLoop, isExceptionOnErrorStatus, isFollowRedirects, resolveProxy, setAddressResolverGroupName, setAllowBlockEventLoop, setAlpnModes, setChannelOptions, setConnectionPoolIdleTimeout, setConnectTimeout, setConnectTtl, setDefaultCharset, setDnsResolutionMode, setEventLoopGroup, setExceptionOnErrorStatus, setFollowRedirects, setHttpVersion, setLoggerName, setLogLevel, setMaxContentLength, setNumOfThreads, setPlaintextMode, setProxyAddress, setProxyPassword, setProxySelector, setProxyType, setProxyUsername, setReadIdleTimeout, setReadTimeout, setRequestTimeout, setShutdownQuietPeriod, setShutdownTimeout, setSslConfiguration, setThreadFactory
-
Field Details
-
PREFIX
Prefix for HTTP Client settings.- See Also:
-
DEFAULT_HEALTHCHECKURI
The default health check uri.- See Also:
-
DEFAULT_HEALTHCHECK
public static final boolean DEFAULT_HEALTHCHECKThe default health check value.- See Also:
-
DEFAULT_HEALTHCHECKINTERVAL_SECONDS
public static final long DEFAULT_HEALTHCHECKINTERVAL_SECONDSThe default health check interval in seconds.- See Also:
-
-
Constructor Details
-
ServiceHttpClientConfiguration
public ServiceHttpClientConfiguration(@Parameter String serviceId, @Nullable @Nullable ServiceHttpClientConfiguration.ServiceConnectionPoolConfiguration connectionPoolConfiguration, @Nullable @Nullable ServiceHttpClientConfiguration.ServiceSslClientConfiguration sslConfiguration, ApplicationConfiguration applicationConfiguration) Creates a new client configuration for the given service ID.- Parameters:
serviceId
- The service idconnectionPoolConfiguration
- The connection pool configurationsslConfiguration
- The SSL configurationapplicationConfiguration
- The application configuration
-
ServiceHttpClientConfiguration
@Deprecated(since="4.3.0") public ServiceHttpClientConfiguration(@Parameter String serviceId, @Nullable @Nullable ServiceHttpClientConfiguration.ServiceConnectionPoolConfiguration connectionPoolConfiguration, @Nullable @Nullable ServiceHttpClientConfiguration.ServiceSslClientConfiguration sslConfiguration, HttpClientConfiguration defaultHttpClientConfiguration) Creates a new client configuration for the given service ID.- Parameters:
serviceId
- The service idconnectionPoolConfiguration
- The connection pool configurationsslConfiguration
- The SSL configurationdefaultHttpClientConfiguration
- The default HTTP client configuration
-
ServiceHttpClientConfiguration
@Deprecated(since="4.6.0") public ServiceHttpClientConfiguration(@Parameter String serviceId, @Nullable @Nullable ServiceHttpClientConfiguration.ServiceConnectionPoolConfiguration connectionPoolConfiguration, @Nullable @Nullable ServiceHttpClientConfiguration.ServiceWebSocketCompressionConfiguration webSocketCompressionConfiguration, @Nullable @Nullable ServiceHttpClientConfiguration.ServiceSslClientConfiguration sslConfiguration, HttpClientConfiguration defaultHttpClientConfiguration) Creates a new client configuration for the given service ID.- Parameters:
serviceId
- The service idconnectionPoolConfiguration
- The connection pool configurationwebSocketCompressionConfiguration
- The WebSocket compression configurationsslConfiguration
- The SSL configurationdefaultHttpClientConfiguration
- The default HTTP client configuration
-
ServiceHttpClientConfiguration
@Inject public ServiceHttpClientConfiguration(@Parameter String serviceId, @Nullable @Nullable ServiceHttpClientConfiguration.ServiceConnectionPoolConfiguration connectionPoolConfiguration, @Nullable @Nullable ServiceHttpClientConfiguration.ServiceWebSocketCompressionConfiguration webSocketCompressionConfiguration, @Nullable ServiceHttpClientConfiguration.ServiceHttp2ClientConfiguration http2Configuration, @Nullable @Nullable ServiceHttpClientConfiguration.ServiceSslClientConfiguration sslConfiguration, HttpClientConfiguration defaultHttpClientConfiguration) Creates a new client configuration for the given service ID.- Parameters:
serviceId
- The service idconnectionPoolConfiguration
- The connection pool configurationwebSocketCompressionConfiguration
- The WebSocket compression configurationhttp2Configuration
- The HTTP/2 configurationsslConfiguration
- The SSL configurationdefaultHttpClientConfiguration
- The default HTTP client configuration
-
-
Method Details
-
getServiceId
The service id.- Returns:
- The ID of the service
-
getUrls
The URLs.- Returns:
- The URLs of the service
-
setUrls
Sets the URIs of the service.- Parameters:
urls
- The URIs
-
setUrl
Sets the URL of the service.- Parameters:
url
- The URI
-
getHealthCheckUri
The URI to check the service for health status.- Returns:
- The health status uri
-
setHealthCheckUri
Sets the health check URI. Default value ("/health").- Parameters:
healthCheckUri
- The health check URI
-
isHealthCheck
public boolean isHealthCheck()Whether the service health should be checked.- Returns:
- True if the health should be checked
-
setHealthCheck
public void setHealthCheck(boolean healthCheck) Sets whether the service health should be checked. Default value (false).- Parameters:
healthCheck
- True if the health should be checked
-
getPath
The context path to use for requests.- Returns:
- The context path
-
setPath
Sets the context path to use for requests.- Parameters:
path
- The context path
-
getContextPath
- Specified by:
getContextPath
in interfaceClientContextPathProvider
- Returns:
- An optional context path
-
getHealthCheckInterval
The default duration to check health status.- Returns:
- The duration
-
setHealthCheckInterval
Sets the default duration to check health status. Default value (30L seconds).- Parameters:
healthCheckInterval
- The duration
-
getConnectionPoolConfiguration
Description copied from class:HttpClientConfiguration
Obtains the connection pool configuration.- Specified by:
getConnectionPoolConfiguration
in classHttpClientConfiguration
- Returns:
- The connection pool configuration.
-
getWebSocketCompressionConfiguration
public HttpClientConfiguration.WebSocketCompressionConfiguration getWebSocketCompressionConfiguration()Description copied from class:HttpClientConfiguration
Obtains the WebSocket compression configuration.- Overrides:
getWebSocketCompressionConfiguration
in classHttpClientConfiguration
- Returns:
- The WebSocket compression configuration.
-
getHttp2Configuration
Description copied from class:HttpClientConfiguration
Obtains the HTTP/2 configuration.- Overrides:
getHttp2Configuration
in classHttpClientConfiguration
- Returns:
- The HTTP/2 configuration.
-
ServiceHttpClientConfiguration(java.lang.String,@io.micronaut.core.annotation.Nullable io.micronaut.http.client.ServiceHttpClientConfiguration.ServiceConnectionPoolConfiguration,@io.micronaut.core.annotation.Nullable io.micronaut.http.client.ServiceHttpClientConfiguration.ServiceWebSocketCompressionConfiguration,io.micronaut.http.client.ServiceHttpClientConfiguration.ServiceHttp2ClientConfiguration,@io.micronaut.core.annotation.Nullable io.micronaut.http.client.ServiceHttpClientConfiguration.ServiceSslClientConfiguration,io.micronaut.http.client.HttpClientConfiguration)
instead.