@@ -320,6 +320,50 @@ router.addRoute('route-http', {
320
320
});
321
321
```
322
322
323
+ Add an http2 route with retries:
324
+
325
+ ``` ts
326
+ router .addRoute (' route-http2-retry' , {
327
+ routeSpec: appmesh .RouteSpec .http2 ({
328
+ weightedTargets: [{ virtualNode: node }],
329
+ retryPolicy: {
330
+ // Retry if the connection failed
331
+ tcpRetryEvents: [appmesh .TcpRetryEvent .CONNECTION_ERROR ],
332
+ // Retry if HTTP responds with a gateway error (502, 503, 504)
333
+ httpRetryEvents: [appmesh .HttpRetryEvent .GATEWAY_ERROR ],
334
+ // Retry five times
335
+ retryAttempts: 5 ,
336
+ // Use a 1 second timeout per retry
337
+ retryTimeout: cdk .Duration .seconds (1 ),
338
+ },
339
+ }),
340
+ });
341
+ ```
342
+
343
+ Add a gRPC route with retries:
344
+
345
+ ``` ts
346
+ router .addRoute (' route-grpc-retry' , {
347
+ routeSpec: appmesh .RouteSpec .grpc ({
348
+ weightedTargets: [{ virtualNode: node }],
349
+ match: { serviceName: ' servicename' },
350
+ retryPolicy: {
351
+ tcpRetryEvents: [appmesh .TcpRetryEvent .CONNECTION_ERROR ],
352
+ httpRetryEvents: [appmesh .HttpRetryEvent .GATEWAY_ERROR ],
353
+ // Retry if gRPC responds that the request was cancelled, a resource
354
+ // was exhausted, or if the service is unavailable
355
+ grpcRetryEvents: [
356
+ appmesh .GrpcRetryEvent .CANCELLED ,
357
+ appmesh .GrpcRetryEvent .RESOURCE_EXHAUSTED ,
358
+ appmesh .GrpcRetryEvent .UNAVAILABLE ,
359
+ ],
360
+ retryAttempts: 5 ,
361
+ retryTimeout: cdk .Duration .seconds (1 ),
362
+ },
363
+ }),
364
+ });
365
+ ```
366
+
323
367
The _ RouteSpec_ class provides an easy interface for defining new protocol specific route specs.
324
368
The ` tcp() ` , ` http() ` and ` http2() ` methods provide the spec necessary to define a protocol specific spec.
325
369
0 commit comments