HttpRetryEvent Enum
HTTP events on which to retry.
| Source | aws-appmesh/lib/route-spec.ts |
|---|
Example
ts
declare const router: appmesh.VirtualRouter;
declare const node: appmesh.VirtualNode;
router.addRoute('route-http2-retry', {
routeSpec: appmesh.RouteSpec.http2({
weightedTargets: [{ virtualNode: node }],
retryPolicy: {
// Retry if the connection failed
tcpRetryEvents: [appmesh.TcpRetryEvent.CONNECTION_ERROR],
// Retry if HTTP responds with a gateway error (502, 503, 504)
httpRetryEvents: [appmesh.HttpRetryEvent.GATEWAY_ERROR],
// Retry five times
retryAttempts: 5,
// Use a 1 second timeout per retry
retryTimeout: Duration.seconds(1),
},
}),
});
python
# router: appmesh.VirtualRouter
# node: appmesh.VirtualNode
router.add_route("route-http2-retry",
route_spec=appmesh.RouteSpec.http2(
weighted_targets=[appmesh.WeightedTarget(virtual_node=node)],
retry_policy=appmesh.HttpRetryPolicy(
# Retry if the connection failed
tcp_retry_events=[appmesh.TcpRetryEvent.CONNECTION_ERROR],
# Retry if HTTP responds with a gateway error (502, 503, 504)
http_retry_events=[appmesh.HttpRetryEvent.GATEWAY_ERROR],
# Retry five times
retry_attempts=5,
# Use a 1 second timeout per retry
retry_timeout=Duration.seconds(1)
)
)
)
java
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());
csharp
// Install: dotnet add package Amazon.CDK.Lib
VirtualRouter router;
VirtualNode node;
router.AddRoute("route-http2-retry", new RouteBaseProps {
RouteSpec = RouteSpec.Http2(new HttpRouteSpecOptions {
WeightedTargets = new [] { new WeightedTarget { VirtualNode = node } },
RetryPolicy = new HttpRetryPolicy {
// Retry if the connection failed
TcpRetryEvents = new [] { TcpRetryEvent.CONNECTION_ERROR },
// Retry if HTTP responds with a gateway error (502, 503, 504)
HttpRetryEvents = new [] { HttpRetryEvent.GATEWAY_ERROR },
// Retry five times
RetryAttempts = 5,
// Use a 1 second timeout per retry
RetryTimeout = Duration.Seconds(1)
}
})
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var router VirtualRouter
var node VirtualNode
router.addRoute(jsii.String("route-http2-retry"), &RouteBaseProps{
RouteSpec: appmesh.RouteSpec_Http2(&HttpRouteSpecOptions{
WeightedTargets: []WeightedTarget{
&WeightedTarget{
VirtualNode: node,
},
},
RetryPolicy: &HttpRetryPolicy{
// Retry if the connection failed
TcpRetryEvents: []cONNECTION_ERROR{
appmesh.TcpRetryEvent_*cONNECTION_ERROR,
},
// Retry if HTTP responds with a gateway error (502, 503, 504)
HttpRetryEvents: []HttpRetryEvent{
appmesh.HttpRetryEvent_GATEWAY_ERROR,
},
// Retry five times
RetryAttempts: jsii.Number(5),
// Use a 1 second timeout per retry
RetryTimeout: awscdk.Duration_Seconds(jsii.Number(1)),
},
}),
})
Members
| Member | Description |
|---|---|
SERVER_ERROR | HTTP status codes 500, 501, 502, 503, 504, 505, 506, 507, 508, 510, and 511. |
GATEWAY_ERROR | HTTP status codes 502, 503, and 504. |
CLIENT_ERROR | HTTP status code 409. |
STREAM_ERROR | Retry on refused stream. |
Referenced by
HttpRetryPolicy.httpRetryEventshttp_retry_eventshttpRetryEventsHttpRetryEventsHttpRetryEvents