com.amazonaws.opensdk.config.TimeoutConfiguration Maven / Gradle / Ivy
Show all versions of aws-java-sdk-opensdk Show documentation
/*
* Copyright 2011-2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package com.amazonaws.opensdk.config;
import com.amazonaws.opensdk.internal.config.ApiGatewayClientConfigurationFactory;
import java.util.Optional;
/**
* Configuration options to customize the various timeouts used by the client.
*/
public class TimeoutConfiguration {
private Integer socketTimeout;
private Integer connectionTimeout;
private Integer httpRequestTimeout;
private Integer totalExecutionTimeout;
/**
* Returns the amount of time to wait (in milliseconds) for data to be transferred over an
* established, open connection before the connection times out and is closed. A value of 0
* means infinity, and isn't recommended.
*
* Default value is {@value ApiGatewayClientConfigurationFactory#DEFAULT_SOCKET_TIMEOUT}.
*
*
* @return The amount of time to wait (in milliseconds) for data to be transferred over an
* established, open connection before the connection times out and is closed.
*/
public Optional getSocketTimeout() {
return Optional.ofNullable(socketTimeout);
}
/**
* Sets the amount of time to wait (in milliseconds) for data to be transferred over an
* established, open connection before the connection times out and is closed.
*
* Default value is {@value ApiGatewayClientConfigurationFactory#DEFAULT_SOCKET_TIMEOUT}.
*
*
* @param socketTimeout The amount of time to wait (in milliseconds) for data to be transferred over an
* established, open connection before the connection is times out and is closed.
*/
public void setSocketTimeout(Integer socketTimeout) {
this.socketTimeout = socketTimeout;
}
/**
* Sets the amount of time to wait (in milliseconds) for data to be transferred over an
* established, open connection before the connection times out and is closed.
*
* Default value is {@value ApiGatewayClientConfigurationFactory#DEFAULT_SOCKET_TIMEOUT}.
*
*
* @param socketTimeout The amount of time to wait (in milliseconds) for data to be transferred over an
* established, open connection before the connection is times out and is closed.
* @return This object for method chaining.
*/
public TimeoutConfiguration socketTimeout(Integer socketTimeout) {
setSocketTimeout(socketTimeout);
return this;
}
/**
* Returns the amount of time to wait (in milliseconds) when initially establishing a connection
* before giving up and timing out. A value of 0 means infinity, and is not recommended.
*
* Default value is {@value com.amazonaws.ClientConfiguration#DEFAULT_CONNECTION_TIMEOUT}.
*
*
* @return The amount of time to wait (in milliseconds) when initially establishing a connection
* before giving up and timing out.
*/
public Optional getConnectionTimeout() {
return Optional.ofNullable(connectionTimeout);
}
/**
* Sets the amount of time to wait (in milliseconds) when initially establishing a connection
* before giving up and timing out.
*
* Default value is {@value com.amazonaws.ClientConfiguration#DEFAULT_CONNECTION_TIMEOUT}.
*
*
* @param connectionTimeout The amount of time to wait (in milliseconds) when initially establishing a
* connection before giving up and timing out.
*/
public void setConnectionTimeout(Integer connectionTimeout) {
this.connectionTimeout = connectionTimeout;
}
/**
* Sets the amount of time to wait (in milliseconds) when initially establishing a connection
* before giving up and timing out.
*
* Default value is {@value com.amazonaws.ClientConfiguration#DEFAULT_CONNECTION_TIMEOUT}.
*
*
* @param connectionTimeout The amount of time to wait (in milliseconds) when initially establishing a
* connection before giving up and timing out.
* @return This object for method chaining.
*/
public TimeoutConfiguration connectionTimeout(Integer connectionTimeout) {
setConnectionTimeout(connectionTimeout);
return this;
}
/**
* Returns the amount of time to wait (in milliseconds) for a HTTP request to complete before
* giving up and timing out.
*
* This feature requires buffering the entire response (for non-streaming APIs) into memory to
* enforce a hard timeout when reading the response. For APIs that return large responses this
* could be expensive.
*
*
* The http request timeout feature doesn't have strict guarantees on how quickly a request is
* aborted when the timeout is breached. The typical case aborts the request within a few
* milliseconds but there may occasionally be requests that don't get aborted until several
* seconds after the timer has been breached. Because of this, this feature
* should not be used when absolute precision is needed.
*
*
* Default value is {@value com.amazonaws.ClientConfiguration#DEFAULT_REQUEST_TIMEOUT},
* which indicates the feature is disabled.
*
*
* @return The amount of time to wait (in milliseconds) for the request to complete before
* giving up and timing out.
*/
public Optional getHttpRequestTimeout() {
return Optional.ofNullable(httpRequestTimeout);
}
/**
* Sets the amount of time to wait (in milliseconds) for a single HTTP request to complete before giving
* up and timing out.
*
* This feature requires buffering the entire response (for non-streaming APIs) into memory to
* enforce a hard timeout when reading the response. For APIs that return large responses this
* could be expensive.
*
*
* The http request timeout feature doesn't have strict guarantees on how quickly a request is
* aborted when the timeout is breached. The typical case aborts the request within a few
* milliseconds but there may occasionally be requests that don't get aborted until several
* seconds after the timer has been breached. Because of this, this feature
* should not be used when absolute precision is needed.
*
*
* This timeout is disabled by default.
*
*
* @param httpRequestTimeout The amount of time to wait (in milliseconds) for the request to complete before
* giving up and timing out.
*/
public void setHttpRequestTimeout(Integer httpRequestTimeout) {
this.httpRequestTimeout = httpRequestTimeout;
}
/**
* Sets the amount of time to wait (in milliseconds) for a single HTTP request to complete before giving
* up and timing out.
*
* This feature requires buffering the entire response (for non-streaming APIs) into memory to
* enforce a hard timeout when reading the response. For APIs that return large responses this
* could be expensive.
*
*
* The http request timeout feature doesn't have strict guarantees on how quickly a request is
* aborted when the timeout is breached. The typical case aborts the request within a few
* milliseconds but there may occasionally be requests that don't get aborted until several
* seconds after the timer has been breached. Because of this, this feature
* should not be used when absolute precision is needed.
*
*
* This timeout is disabled by default.
*
*
* @param httpRequestTimeout The amount of time to wait (in milliseconds) for the request to complete before
* giving up and timing out.
* @return This object for method chaining.
*/
public TimeoutConfiguration httpRequestTimeout(Integer httpRequestTimeout) {
setHttpRequestTimeout(httpRequestTimeout);
return this;
}
/**
* Returns the amount of time (in milliseconds) to allow the client to complete the execution of
* an API call. This timeout covers the entire client execution except for marshalling. This
* includes all HTTP requests (even retries), unmarshalling, etc.
*
* This feature requires buffering the entire response (for non-streaming APIs) into memory to
* enforce a hard timeout when reading the response. For APIs that return large responses this
* could be expensive.
*
*
* The total execution timeout feature doesn't have strict guarantees on how quickly a request
* is aborted when the timeout is breached. The typical case aborts the request within a few
* milliseconds but there may occasionally be requests that don't get aborted until several
* seconds after the timer has been breached. Because of this, the client execution timeout
* feature should not be used when absolute precision is needed.
*
*
* This timeout is disabled by default.
*
*
* @return The amount of time (in milliseconds) to allow the client to complete the execution of
* an API call.
*/
public Optional getTotalExecutionTimeout() {
return Optional.ofNullable(totalExecutionTimeout);
}
/**
* Sets the amount of time (in milliseconds) to allow the client to complete the execution of
* an API call. This timeout covers the entire client execution except for marshalling. This
* includes all HTTP requests (even retries), unmarshalling, etc.
*
* This feature requires buffering the entire response (for non-streaming APIs) into memory to
* enforce a hard timeout when reading the response. For APIs that return large responses this
* could be expensive.
*
*
* The total execution timeout feature doesn't have strict guarantees on how quickly a request
* is aborted when the timeout is breached. The typical case aborts the request within a few
* milliseconds but there may occasionally be requests that don't get aborted until several
* seconds after the timer has been breached. Because of this, the client execution timeout
* feature should not be used when absolute precision is needed.
*
*
* This timeout is disabled by default.
*
*
* @param totalExecutionTimeout The amount of time (in milliseconds) to allow the client to complete the execution
* of an API call.
*/
public void setTotalExecutionTimeout(Integer totalExecutionTimeout) {
this.totalExecutionTimeout = totalExecutionTimeout;
}
/**
* Sets the amount of time (in milliseconds) to allow the client to complete the execution of
* an API call. This timeout covers the entire client execution except for marshalling. This
* includes all HTTP requests (even retries), unmarshalling, etc.
*
* This feature requires buffering the entire response (for non-streaming APIs) into memory to
* enforce a hard timeout when reading the response. For APIs that return large responses this
* could be expensive.
*
*
* The total execution timeout feature doesn't have strict guarantees on how quickly a request
* is aborted when the timeout is breached. The typical case aborts the request within a few
* milliseconds but there may occasionally be requests that don't get aborted until several
* seconds after the timer has been breached. Because of this, the client execution timeout
* feature should not be used when absolute precision is needed.
*
*
* This timeout is disabled by default.
*
*
* @param totalExecutionTimeout The amount of time (in milliseconds) to allow the client to complete the execution
* of an API call.
* @return This object for method chaining.
*/
public TimeoutConfiguration totalExecutionTimeout(Integer totalExecutionTimeout) {
setTotalExecutionTimeout(totalExecutionTimeout);
return this;
}
}