Package io.micronaut.http.client
Class ServiceHttpClientConfiguration
- java.lang.Object
-
- io.micronaut.http.client.HttpClientConfiguration
-
- io.micronaut.http.client.ServiceHttpClientConfiguration
-
- All Implemented Interfaces:
io.micronaut.http.context.ClientContextPathProvider
@EachProperty("micronaut.http.services") public class ServiceHttpClientConfiguration extends HttpClientConfiguration implements io.micronaut.http.context.ClientContextPathProviderAllows defining HTTP client configurations via themicronaut.http.servicessetting.- Since:
- 1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classServiceHttpClientConfiguration.ServiceConnectionPoolConfigurationThe default connection pool configuration.static classServiceHttpClientConfiguration.ServiceSslClientConfigurationThe default connection pool configuration.-
Nested classes/interfaces inherited from class io.micronaut.http.client.HttpClientConfiguration
HttpClientConfiguration.ConnectionPoolConfiguration
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_HEALTHCHECKThe default health check value.static longDEFAULT_HEALTHCHECKINTERVAL_SECONDSThe default health check interval in seconds.static java.lang.StringDEFAULT_HEALTHCHECKURIThe default health check uri.static java.lang.StringPREFIXPrefix for HTTP Client settings.-
Fields inherited from class io.micronaut.http.client.HttpClientConfiguration
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
Constructors Constructor Description ServiceHttpClientConfiguration(java.lang.String serviceId, ServiceHttpClientConfiguration.ServiceConnectionPoolConfiguration connectionPoolConfiguration, ServiceHttpClientConfiguration.ServiceSslClientConfiguration sslConfiguration, HttpClientConfiguration defaultHttpClientConfiguration)Creates a new client configuration for the given service ID.ServiceHttpClientConfiguration(java.lang.String serviceId, ServiceHttpClientConfiguration.ServiceConnectionPoolConfiguration connectionPoolConfiguration, ServiceHttpClientConfiguration.ServiceSslClientConfiguration sslConfiguration, io.micronaut.runtime.ApplicationConfiguration applicationConfiguration)Creates a new client configuration for the given service ID.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HttpClientConfiguration.ConnectionPoolConfigurationgetConnectionPoolConfiguration()Obtains the connection pool configuration.java.util.Optional<java.lang.String>getContextPath()java.time.DurationgetHealthCheckInterval()The default duration to check health status.java.lang.StringgetHealthCheckUri()The URI to check the service for health status.java.util.Optional<java.lang.String>getPath()The context path to use for requests.java.lang.StringgetServiceId()The service id.java.util.List<java.net.URI>getUrls()The URLs.booleanisHealthCheck()Whether the service health should be checked.voidsetHealthCheck(boolean healthCheck)Sets whether the service health should be checked.voidsetHealthCheckInterval(java.time.Duration healthCheckInterval)Sets the default duration to check health status.voidsetHealthCheckUri(java.lang.String healthCheckUri)Sets the health check URI.voidsetPath(java.lang.String path)Sets the context path to use for requests.voidsetUrl(java.net.URI url)Sets the URL of the service.voidsetUrls(java.util.List<java.net.URI> urls)Sets the URIs of the service.-
Methods inherited from class io.micronaut.http.client.HttpClientConfiguration
getChannelOptions, getConnectionPoolIdleTimeout, getConnectTimeout, getConnectTtl, getDefaultCharset, getEventLoopGroup, getHttpVersion, getLoggerName, getLogLevel, getMaxContentLength, getNumOfThreads, getProxyAddress, getProxyPassword, getProxySelector, getProxyType, getProxyUsername, getReadIdleTimeout, getReadTimeout, getShutdownQuietPeriod, getShutdownTimeout, getSslConfiguration, getThreadFactory, isExceptionOnErrorStatus, isFollowRedirects, resolveProxy, setChannelOptions, setConnectionPoolIdleTimeout, setConnectTimeout, setConnectTtl, setDefaultCharset, setEventLoopGroup, setExceptionOnErrorStatus, setFollowRedirects, setHttpVersion, setLoggerName, setLogLevel, setMaxContentLength, setNumOfThreads, setProxyAddress, setProxyPassword, setProxySelector, setProxyType, setProxyUsername, setReadIdleTimeout, setReadTimeout, setShutdownQuietPeriod, setShutdownTimeout, setSslConfiguration, setThreadFactory
-
-
-
-
Field Detail
-
PREFIX
public static final java.lang.String PREFIX
Prefix for HTTP Client settings.- See Also:
- Constant Field Values
-
DEFAULT_HEALTHCHECKURI
public static final java.lang.String DEFAULT_HEALTHCHECKURI
The default health check uri.- See Also:
- Constant Field Values
-
DEFAULT_HEALTHCHECK
public static final boolean DEFAULT_HEALTHCHECK
The default health check value.- See Also:
- Constant Field Values
-
DEFAULT_HEALTHCHECKINTERVAL_SECONDS
public static final long DEFAULT_HEALTHCHECKINTERVAL_SECONDS
The default health check interval in seconds.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ServiceHttpClientConfiguration
public ServiceHttpClientConfiguration(@Parameter java.lang.String serviceId, @Nullable ServiceHttpClientConfiguration.ServiceConnectionPoolConfiguration connectionPoolConfiguration, @Nullable ServiceHttpClientConfiguration.ServiceSslClientConfiguration sslConfiguration, io.micronaut.runtime.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 java.lang.String serviceId, @Nullable ServiceHttpClientConfiguration.ServiceConnectionPoolConfiguration connectionPoolConfiguration, @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 Detail
-
getServiceId
public java.lang.String getServiceId()
The service id.- Returns:
- The ID of the service
-
getUrls
public java.util.List<java.net.URI> getUrls()
The URLs.- Returns:
- The URLs of the service
-
setUrls
public void setUrls(java.util.List<java.net.URI> urls)
Sets the URIs of the service.- Parameters:
urls- The URIs
-
setUrl
public void setUrl(java.net.URI url)
Sets the URL of the service.- Parameters:
url- The URI
-
getHealthCheckUri
public java.lang.String getHealthCheckUri()
The URI to check the service for health status.- Returns:
- The health status uri
-
setHealthCheckUri
public void setHealthCheckUri(java.lang.String healthCheckUri)
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
public java.util.Optional<java.lang.String> getPath()
The context path to use for requests.- Returns:
- The context path
-
setPath
public void setPath(java.lang.String path)
Sets the context path to use for requests.- Parameters:
path- The context path
-
getContextPath
public java.util.Optional<java.lang.String> getContextPath()
- Specified by:
getContextPathin interfaceio.micronaut.http.context.ClientContextPathProvider
-
getHealthCheckInterval
public java.time.Duration getHealthCheckInterval()
The default duration to check health status.- Returns:
- The duration
-
setHealthCheckInterval
public void setHealthCheckInterval(java.time.Duration healthCheckInterval)
Sets the default duration to check health status. Default value (30L seconds).- Parameters:
healthCheckInterval- The duration
-
getConnectionPoolConfiguration
public HttpClientConfiguration.ConnectionPoolConfiguration getConnectionPoolConfiguration()
Description copied from class:HttpClientConfigurationObtains the connection pool configuration.- Specified by:
getConnectionPoolConfigurationin classHttpClientConfiguration- Returns:
- The connection pool configuration.
-
-