Package com.bandwidth.http.client
Class HttpClientConfiguration
- java.lang.Object
-
- com.bandwidth.http.client.HttpClientConfiguration
-
- All Implemented Interfaces:
ReadonlyHttpClientConfiguration
public class HttpClientConfiguration extends Object implements ReadonlyHttpClientConfiguration
Class to hold HTTP Client Configuration.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HttpClientConfiguration.Builder
Class to build instances ofHttpClientConfiguration
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getBackOffFactor()
To use in calculation of wait time for next request in case of failure.okhttp3.OkHttpClient
getHttpClientInstance()
The OkHttpClient instance used to make the HTTP calls.Set<HttpMethod>
getHttpMethodsToRetry()
Http methods to retry against.Set<Integer>
getHttpStatusCodesToRetry()
Http status codes to retry against.long
getMaximumRetryWaitTime()
The maximum wait time for overall retrying requests.int
getNumberOfRetries()
The number of retries to make.long
getRetryInterval()
To use in calculation of wait time for next request in case of failure.long
getTimeout()
The timeout in seconds to use for making HTTP requests.HttpClientConfiguration.Builder
newBuilder()
Builds a newHttpClientConfiguration.Builder
object.boolean
shouldOverrideHttpClientConfigurations()
Allow the SDK to override HTTP client instance's settings used for features like retries, timeouts etc.boolean
shouldRetryOnTimeout()
Whether to retry on request timeout.String
toString()
Converts this HttpClientConfiguration into string format.
-
-
-
Method Detail
-
getTimeout
public long getTimeout()
The timeout in seconds to use for making HTTP requests.- Specified by:
getTimeout
in interfaceReadonlyHttpClientConfiguration
- Returns:
- timeout
-
getNumberOfRetries
public int getNumberOfRetries()
The number of retries to make.- Specified by:
getNumberOfRetries
in interfaceReadonlyHttpClientConfiguration
- Returns:
- numberOfRetries
-
getBackOffFactor
public int getBackOffFactor()
To use in calculation of wait time for next request in case of failure.- Specified by:
getBackOffFactor
in interfaceReadonlyHttpClientConfiguration
- Returns:
- backOffFactor
-
getRetryInterval
public long getRetryInterval()
To use in calculation of wait time for next request in case of failure.- Specified by:
getRetryInterval
in interfaceReadonlyHttpClientConfiguration
- Returns:
- retryInterval
-
getHttpStatusCodesToRetry
public Set<Integer> getHttpStatusCodesToRetry()
Http status codes to retry against.- Specified by:
getHttpStatusCodesToRetry
in interfaceReadonlyHttpClientConfiguration
- Returns:
- httpStatusCodesToRetry
-
getHttpMethodsToRetry
public Set<HttpMethod> getHttpMethodsToRetry()
Http methods to retry against.- Specified by:
getHttpMethodsToRetry
in interfaceReadonlyHttpClientConfiguration
- Returns:
- httpMethodsToRetry
-
getMaximumRetryWaitTime
public long getMaximumRetryWaitTime()
The maximum wait time for overall retrying requests.- Specified by:
getMaximumRetryWaitTime
in interfaceReadonlyHttpClientConfiguration
- Returns:
- maximumRetryWaitTime
-
shouldRetryOnTimeout
public boolean shouldRetryOnTimeout()
Whether to retry on request timeout.- Specified by:
shouldRetryOnTimeout
in interfaceReadonlyHttpClientConfiguration
- Returns:
- shouldRetryOnTimeout
-
getHttpClientInstance
public okhttp3.OkHttpClient getHttpClientInstance()
The OkHttpClient instance used to make the HTTP calls.- Specified by:
getHttpClientInstance
in interfaceReadonlyHttpClientConfiguration
- Returns:
- httpClientInstance
-
shouldOverrideHttpClientConfigurations
public boolean shouldOverrideHttpClientConfigurations()
Allow the SDK to override HTTP client instance's settings used for features like retries, timeouts etc.- Specified by:
shouldOverrideHttpClientConfigurations
in interfaceReadonlyHttpClientConfiguration
- Returns:
- overrideHttpClientConfigurations
-
toString
public String toString()
Converts this HttpClientConfiguration into string format.
-
newBuilder
public HttpClientConfiguration.Builder newBuilder()
Builds a newHttpClientConfiguration.Builder
object. Creates the instance with the current state.- Returns:
- a new
HttpClientConfiguration.Builder
object
-
-