GrpcRetryPolicy Struct
gRPC retry policy.
| Source | aws-appmesh/lib/route-spec.ts |
|---|
Example
ts
declare const router: appmesh.VirtualRouter;
declare const node: appmesh.VirtualNode;
router.addRoute('route-grpc-retry', {
routeSpec: appmesh.RouteSpec.grpc({
weightedTargets: [{ virtualNode: node }],
match: { serviceName: 'servicename' },
retryPolicy: {
tcpRetryEvents: [appmesh.TcpRetryEvent.CONNECTION_ERROR],
httpRetryEvents: [appmesh.HttpRetryEvent.GATEWAY_ERROR],
// Retry if gRPC responds that the request was cancelled, a resource
// was exhausted, or if the service is unavailable
grpcRetryEvents: [
appmesh.GrpcRetryEvent.CANCELLED,
appmesh.GrpcRetryEvent.RESOURCE_EXHAUSTED,
appmesh.GrpcRetryEvent.UNAVAILABLE,
],
retryAttempts: 5,
retryTimeout: Duration.seconds(1),
},
}),
});
python
# router: appmesh.VirtualRouter
# node: appmesh.VirtualNode
router.add_route("route-grpc-retry",
route_spec=appmesh.RouteSpec.grpc(
weighted_targets=[appmesh.WeightedTarget(virtual_node=node)],
match=appmesh.GrpcRouteMatch(service_name="servicename"),
retry_policy=appmesh.GrpcRetryPolicy(
tcp_retry_events=[appmesh.TcpRetryEvent.CONNECTION_ERROR],
http_retry_events=[appmesh.HttpRetryEvent.GATEWAY_ERROR],
# Retry if gRPC responds that the request was cancelled, a resource
# was exhausted, or if the service is unavailable
grpc_retry_events=[appmesh.GrpcRetryEvent.CANCELLED, appmesh.GrpcRetryEvent.RESOURCE_EXHAUSTED, appmesh.GrpcRetryEvent.UNAVAILABLE
],
retry_attempts=5,
retry_timeout=Duration.seconds(1)
)
)
)
java
VirtualRouter router;
VirtualNode node;
router.addRoute("route-grpc-retry", RouteBaseProps.builder()
.routeSpec(RouteSpec.grpc(GrpcRouteSpecOptions.builder()
.weightedTargets(List.of(WeightedTarget.builder().virtualNode(node).build()))
.match(GrpcRouteMatch.builder().serviceName("servicename").build())
.retryPolicy(GrpcRetryPolicy.builder()
.tcpRetryEvents(List.of(TcpRetryEvent.CONNECTION_ERROR))
.httpRetryEvents(List.of(HttpRetryEvent.GATEWAY_ERROR))
// Retry if gRPC responds that the request was cancelled, a resource
// was exhausted, or if the service is unavailable
.grpcRetryEvents(List.of(GrpcRetryEvent.CANCELLED, GrpcRetryEvent.RESOURCE_EXHAUSTED, GrpcRetryEvent.UNAVAILABLE))
.retryAttempts(5)
.retryTimeout(Duration.seconds(1))
.build())
.build()))
.build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
VirtualRouter router;
VirtualNode node;
router.AddRoute("route-grpc-retry", new RouteBaseProps {
RouteSpec = RouteSpec.Grpc(new GrpcRouteSpecOptions {
WeightedTargets = new [] { new WeightedTarget { VirtualNode = node } },
Match = new GrpcRouteMatch { ServiceName = "servicename" },
RetryPolicy = new GrpcRetryPolicy {
TcpRetryEvents = new [] { TcpRetryEvent.CONNECTION_ERROR },
HttpRetryEvents = new [] { HttpRetryEvent.GATEWAY_ERROR },
// Retry if gRPC responds that the request was cancelled, a resource
// was exhausted, or if the service is unavailable
GrpcRetryEvents = new [] { GrpcRetryEvent.CANCELLED, GrpcRetryEvent.RESOURCE_EXHAUSTED, GrpcRetryEvent.UNAVAILABLE },
RetryAttempts = 5,
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-grpc-retry"), &RouteBaseProps{
RouteSpec: appmesh.RouteSpec_Grpc(&GrpcRouteSpecOptions{
WeightedTargets: []WeightedTarget{
&WeightedTarget{
VirtualNode: node,
},
},
Match: &GrpcRouteMatch{
ServiceName: jsii.String("servicename"),
},
RetryPolicy: &GrpcRetryPolicy{
TcpRetryEvents: []cONNECTION_ERROR{
appmesh.TcpRetryEvent_*cONNECTION_ERROR,
},
HttpRetryEvents: []HttpRetryEvent{
appmesh.HttpRetryEvent_GATEWAY_ERROR,
},
// Retry if gRPC responds that the request was cancelled, a resource
// was exhausted, or if the service is unavailable
GrpcRetryEvents: []GrpcRetryEvent{
appmesh.GrpcRetryEvent_CANCELLED,
appmesh.GrpcRetryEvent_RESOURCE_EXHAUSTED,
appmesh.GrpcRetryEvent_UNAVAILABLE,
},
RetryAttempts: jsii.Number(5),
RetryTimeout: awscdk.Duration_Seconds(jsii.Number(1)),
},
}),
})
Properties
grpcRetryEventsoptionalGrpcRetryEvent[]grpc_retry_eventsoptionaltyping.List[GrpcRetryEvent]grpcRetryEventsoptionalList<GrpcRetryEvent>GrpcRetryEventsoptionalGrpcRetryEvent[]GrpcRetryEventsoptional*[]GrpcRetryEvent #gRPC events on which to retry.
Default: no retries for gRPC events
You must specify at least one value for at least one types of retry events.
httpRetryEventsoptionalHttpRetryEvent[]http_retry_eventsoptionaltyping.List[HttpRetryEvent]httpRetryEventsoptionalList<HttpRetryEvent>HttpRetryEventsoptionalHttpRetryEvent[]HttpRetryEventsoptional*[]HttpRetryEvent #Specify HTTP events on which to retry.
Default: no retries for http events
You must specify at least one value for at least one types of retry events.
retryAttemptsnumberretry_attemptsint | floatretryAttemptsNumberRetryAttemptsdoubleRetryAttempts*float64 required #The maximum number of retry attempts.
retryTimeoutDurationretry_timeoutDurationretryTimeoutDurationRetryTimeoutDurationRetryTimeoutDuration required #The timeout for each retry attempt.
tcpRetryEventsoptionalTcpRetryEvent[]tcp_retry_eventsoptionaltyping.List[TcpRetryEvent]tcpRetryEventsoptionalList<TcpRetryEvent>TcpRetryEventsoptionalTcpRetryEvent[]TcpRetryEventsoptional*[]TcpRetryEvent #TCP events on which to retry.
Default: no retries for tcp events
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.