Skip to content

Commit ea43aa2

Browse files
author
Kolomiets
committed
Extend readme with list of patterns covered
1 parent 2e12379 commit ea43aa2

File tree

6 files changed

+92
-2
lines changed

6 files changed

+92
-2
lines changed

README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,93 @@
99

1010
*cdk-stepfunctions-patterns* library is a set of [AWS CDK](https://aws.amazon.com/cdk/) constructs that provide
1111
resiliency patterns implementation for AWS Step Functions.
12+
13+
## Try / Catch pattern
14+
15+
### Example
16+
```typescript
17+
import * as sfn from '@aws-cdk/aws-stepfunctions';
18+
import { TryTask } from 'cdk-stepfunctions-patterns';
19+
20+
// ...
21+
22+
new sfn.StateMachine(this, 'TryCatchStepMachine', {
23+
definition: new TryTask(this, "TryCatch", {
24+
tryProcess: new sfn.Pass(this, 'A1').next(new sfn.Pass(this, 'B1')),
25+
catchProcess: new sfn.Pass(this, 'catchHandler'),
26+
// optional configuration properties
27+
catchProps: {
28+
errors: ['Lambda.AWSLambdaException'],
29+
resultPath: "$.ErrorDetails"
30+
}
31+
})
32+
})
33+
```
34+
35+
### Resulting StepFunction
36+
![](doc/tryCatch.png)
37+
38+
39+
## Try / Finally pattern
40+
41+
### Example
42+
43+
```typescript
44+
import * as sfn from '@aws-cdk/aws-stepfunctions';
45+
import { TryTask } from 'cdk-stepfunctions-patterns';
46+
47+
// ...
48+
49+
new sfn.StateMachine(this, 'TryFinallyStepMachine', {
50+
definition: new TryTask(this, "TryFinally", {
51+
tryProcess: new sfn.Pass(this, 'A2').next(new sfn.Pass(this, 'B2')),
52+
finallyProcess: new sfn.Pass(this, 'finallyHandler'),
53+
// optional configuration properties
54+
catchErrorPath: "$.FinallyErrorDetails"
55+
})
56+
})
57+
```
58+
59+
### Resulting StepFunction
60+
![](doc/tryFinally.png)
61+
62+
## Try / Catch / Finally pattern
63+
64+
### Example
65+
```typescript
66+
import * as sfn from '@aws-cdk/aws-stepfunctions';
67+
import { TryTask } from 'cdk-stepfunctions-patterns';
68+
69+
// ...
70+
71+
new sfn.StateMachine(this, 'TryCatchFinallyStepMachine', {
72+
definition: new TryTask(this, "TryCatchFinalli", {
73+
tryProcess: new sfn.Pass(this, 'A3').next(new sfn.Pass(this, 'B3')),
74+
catchProcess: new sfn.Pass(this, 'catchHandler3'),
75+
finallyProcess: new sfn.Pass(this, 'finallyHandler3')
76+
})
77+
})
78+
```
79+
80+
### Resulting StepFunction
81+
![](doc/tryCatchFinally.png)
82+
83+
## Retry with backoff and jitter
84+
85+
### Example
86+
```typescript
87+
import * as sfn from '@aws-cdk/aws-stepfunctions';
88+
import { RetryWithJitterTask } from 'cdk-stepfunctions-patterns';
89+
90+
// ...
91+
92+
new sfn.StateMachine(this, 'RetryWithJitterStepMachine', {
93+
definition: new RetryWithJitterTask(this, "AWithJitter", {
94+
tryProcess: new sfn.Pass(this, 'A4').next(new sfn.Pass(this, 'B4')),
95+
retryProps: { errors: ["States.ALL"], maxAttempts: 3 }
96+
})
97+
})
98+
```
99+
100+
### Resulting StepFunction
101+
![](doc/retryWithJitter.png)

doc/retryWithJitter.png

36.5 KB
Loading

doc/tryCatch.png

11.9 KB
Loading

doc/tryCatchFinally.png

20.6 KB
Loading

doc/tryFinally.png

12.2 KB
Loading

lib/construct/TryTask.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export interface TryProps {
4848
/**
4949
* JSONPath expression to indicate where to map caught exception details.
5050
*/
51-
readonly catchErrorPath?: string;
51+
readonly finallyErrorPath?: string;
5252

5353
/**
5454
* Optional finally chain to execute.
@@ -87,7 +87,7 @@ export class TryTask extends sfn.Parallel {
8787
})
8888
.branch(process)
8989
.addCatch(props.finallyProcess, {
90-
resultPath: props.catchErrorPath
90+
resultPath: props.finallyErrorPath
9191
})
9292
.next(props.finallyProcess);
9393
}

0 commit comments

Comments
 (0)