Interface HttpRetryPolicy

All Superinterfaces:
software.amazon.jsii.JsiiSerializable
All Known Subinterfaces:
GrpcRetryPolicy
All Known Implementing Classes:
GrpcRetryPolicy.Jsii$Proxy, HttpRetryPolicy.Jsii$Proxy

@Generated(value="jsii-pacmak/1.103.1 (build bef2dea)", date="2024-10-05T03:43:38.671Z") @Stability(Stable) public interface HttpRetryPolicy extends software.amazon.jsii.JsiiSerializable
HTTP retry policy.

Example:

 VirtualRouter router;
 VirtualNode node;
 router.addRoute("route-http2-retry", RouteBaseProps.builder()
         .routeSpec(RouteSpec.http2(HttpRouteSpecOptions.builder()
                 .weightedTargets(List.of(WeightedTarget.builder().virtualNode(node).build()))
                 .retryPolicy(HttpRetryPolicy.builder()
                         // Retry if the connection failed
                         .tcpRetryEvents(List.of(TcpRetryEvent.CONNECTION_ERROR))
                         // Retry if HTTP responds with a gateway error (502, 503, 504)
                         .httpRetryEvents(List.of(HttpRetryEvent.GATEWAY_ERROR))
                         // Retry five times
                         .retryAttempts(5)
                         // Use a 1 second timeout per retry
                         .retryTimeout(Duration.seconds(1))
                         .build())
                 .build()))
         .build());
 
  • Method Details

    • getRetryAttempts

      @Stability(Stable) @NotNull Number getRetryAttempts()
      The maximum number of retry attempts.
    • getRetryTimeout

      @Stability(Stable) @NotNull Duration getRetryTimeout()
      The timeout for each retry attempt.
    • getHttpRetryEvents

      @Stability(Stable) @Nullable default List<HttpRetryEvent> getHttpRetryEvents()
      Specify HTTP events on which to retry.

      You must specify at least one value for at least one types of retry events.

      Default: - no retries for http events

    • getTcpRetryEvents

      @Stability(Stable) @Nullable default List<TcpRetryEvent> getTcpRetryEvents()
      TCP events on which to retry.

      The event occurs before any processing of a request has started and is encountered when the upstream is temporarily or permanently unavailable. You must specify at least one value for at least one types of retry events.

      Default: - no retries for tcp events

    • builder

      @Stability(Stable) static HttpRetryPolicy.Builder builder()
      Returns:
      a HttpRetryPolicy.Builder of HttpRetryPolicy