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 default connection pool configuration.Nested classes/interfaces inherited from class io.micronaut.http.client.HttpClientConfiguration
HttpClientConfiguration.ConnectionPoolConfiguration
-
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_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) Creates a new client configuration for the given service ID.ServiceHttpClientConfiguration
(String serviceId, @Nullable ServiceHttpClientConfiguration.ServiceConnectionPoolConfiguration connectionPoolConfiguration, @Nullable ServiceHttpClientConfiguration.ServiceSslClientConfiguration sslConfiguration, ApplicationConfiguration applicationConfiguration) 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.getPath()
The context path to use for requests.The service id.getUrls()
The URLs.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
getAlpnModes, getChannelOptions, getConnectionPoolIdleTimeout, getConnectTimeout, getConnectTtl, getDefaultCharset, getEventLoopGroup, getHttpVersion, getLoggerName, getLogLevel, getMaxContentLength, getNumOfThreads, getPlaintextMode, getProxyAddress, getProxyPassword, getProxySelector, getProxyType, getProxyUsername, getReadIdleTimeout, getReadTimeout, getShutdownQuietPeriod, getShutdownTimeout, getSslConfiguration, getThreadFactory, isAllowBlockEventLoop, isExceptionOnErrorStatus, isFollowRedirects, resolveProxy, setAllowBlockEventLoop, setAlpnModes, setChannelOptions, setConnectionPoolIdleTimeout, setConnectTimeout, setConnectTtl, setDefaultCharset, setEventLoopGroup, setExceptionOnErrorStatus, setFollowRedirects, setHttpVersion, setLoggerName, setLogLevel, setMaxContentLength, setNumOfThreads, setPlaintextMode, setProxyAddress, setProxyPassword, setProxySelector, setProxyType, setProxyUsername, setReadIdleTimeout, setReadTimeout, 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
@Inject 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
-
-
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.
-