CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-aws-sdk-kotlin--aws-http-jvm

HTTP core functionality for AWS service clients in the AWS SDK for Kotlin, providing user agent management, retry policies, and HTTP middleware.

Pending
Overview
Eval results
Files

retry-policies.mddocs/

Retry Policies

AWS-specific retry policies that extend the standard retry policy with AWS service-specific exception handling, providing intelligent retry logic for transient failures and service throttling.

Capabilities

AwsRetryPolicy

The main retry policy class that implements AWS-specific retry logic with exponential backoff and jitter.

/**
 * AWS-specific retry policy that extends StandardRetryPolicy with AWS service exception handling
 */
open class AwsRetryPolicy : StandardRetryPolicy() {
    companion object {
        /**
         * The default retry policy instance used by AWS service clients
         */
        val Default: AwsRetryPolicy
        
        internal val knownErrorTypes: Map<String, RetryErrorType>
        internal val knownStatusCodes: Map<Int, RetryErrorType>
    }
    
    /**
     * Evaluates AWS-specific exceptions to determine retry behavior
     * @param ex The exception to evaluate
     * @return RetryDirective indicating whether to retry, or null to use default behavior
     */
    protected override fun evaluateSpecificExceptions(ex: Throwable): RetryDirective?
}

Usage Examples:

import aws.sdk.kotlin.runtime.http.retries.AwsRetryPolicy

// Use the default AWS retry policy
val retryPolicy = AwsRetryPolicy.Default

// Create a custom retry policy (extending AwsRetryPolicy)
class CustomAwsRetryPolicy : AwsRetryPolicy() {
    protected override fun evaluateSpecificExceptions(ex: Throwable): RetryDirective? {
        // Custom retry logic
        return when (ex) {
            is CustomServiceException -> RetryDirective.RetryError(RetryErrorType.Transient)
            else -> super.evaluateSpecificExceptions(ex)
        }
    }
}

val customRetryPolicy = CustomAwsRetryPolicy()

Integration with HTTP Client

The retry policy integrates with the broader HTTP client infrastructure:

import aws.smithy.kotlin.runtime.http.request.HttpRequest
import aws.smithy.kotlin.runtime.http.response.HttpResponse

// Retry policies are typically configured at the service client level
// and work with the HTTP engine to handle transient failures

Known Error Types

The AWS retry policy recognizes specific error codes and HTTP status codes for intelligent retry handling:

Throttling Errors

// Error codes that indicate throttling (should be retried with backoff)
val throttlingErrors = mapOf(
    "BandwidthLimitExceeded" to RetryErrorType.Throttling,
    "EC2ThrottledException" to RetryErrorType.Throttling,
    "LimitExceededException" to RetryErrorType.Throttling,
    "PriorRequestNotComplete" to RetryErrorType.Throttling,
    "ProvisionedThroughputExceededException" to RetryErrorType.Throttling,
    "RequestLimitExceeded" to RetryErrorType.Throttling,
    "RequestThrottled" to RetryErrorType.Throttling,
    "RequestThrottledException" to RetryErrorType.Throttling,
    "SlowDown" to RetryErrorType.Throttling,
    "ThrottledException" to RetryErrorType.Throttling,
    "Throttling" to RetryErrorType.Throttling,
    "ThrottlingException" to RetryErrorType.Throttling,
    "TooManyRequestsException" to RetryErrorType.Throttling,
    "TransactionInProgressException" to RetryErrorType.Throttling
)

Transient Errors

// Error codes that indicate transient failures (should be retried)
val transientErrors = mapOf(
    "IDPCommunicationError" to RetryErrorType.Transient,
    "RequestTimeout" to RetryErrorType.Transient,
    "RequestTimeoutException" to RetryErrorType.Transient
)

HTTP Status Codes

// HTTP status codes that should trigger retries
val retryableStatusCodes = mapOf(
    500 to RetryErrorType.Transient, // Internal Server Error
    502 to RetryErrorType.Transient, // Bad Gateway
    503 to RetryErrorType.Transient, // Service Unavailable
    504 to RetryErrorType.Transient  // Gateway Timeout
)

Configuration

Retry policies can be configured with various parameters:

  • Maximum Attempts: Total number of retry attempts (including initial request)
  • Base Delay: Initial delay before first retry attempt
  • Maximum Delay: Cap on exponential backoff delay
  • Jitter: Randomization to prevent thundering herd problems
  • Backoff Strategy: Exponential, linear, or custom backoff algorithms

Install with Tessl CLI

npx tessl i tessl/maven-aws-sdk-kotlin--aws-http-jvm

docs

business-metrics.md

index.md

interceptors.md

middleware.md

retry-policies.md

user-agent.md

tile.json