Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bea8fcd

Browse files
committed
Added cli commands template.
1 parent eb4e981 commit bea8fcd

File tree

2 files changed

+86
-34
lines changed

2 files changed

+86
-34
lines changed

‎docs/cli-commands.txt‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
TESTING SCENARIOS CLI COMMANDS
2+
--------------------------------------------------
3+
Using your text editor, replace the state-machine-arn and region parameters.
4+
5+
6+
7+
1 - ErrProcessOrder
8+
-------------------------
9+
aws stepfunctions start-execution \
10+
--state-machine-arn "arn:aws:states:[REGION]:[ACCOUNT NUMBER]:stateMachine:[STATEMACHINE-NAME]" \
11+
--input "{\"order_id\": \"1ae4501d-ed92-4b27-bf0e-fd978ed45127\", \"order_date\": \"2018年10月19日T10:50:16+08:00\", \"customer_id\": \"0d52eeef-52a1-4e6e-a5b1-d0515121306c\", \"items\": [{ \"item_id\": \"929\", \"qty\": 3.0, \"description\": \"Cart item 1\", \"unit_price\": 9.99 }]}" \
12+
--region [AWS_REGION]
13+
14+
11 - ErrUpdateOrderStatus
15+
-------------------------
16+
aws stepfunctions start-execution \
17+
--state-machine-arn "arn:aws:states:[REGION]:[ACCOUNT NUMBER]:stateMachine:[STATEMACHINE-NAME]" \
18+
--input "{\"order_id\": \"11328abd-368d-43fd-bd4f-db15b5b63951\", \"order_date\": \"2018年10月19日T10:50:16+08:00\", \"customer_id\": \"8d04ea6f-c6b2-4422-8550-839a16f01feb\", \"items\": [{ \"item_id\": \"567\", \"qty\": 1.0, \"description\": \"Cart item 1\", \"unit_price\": 199.99 }]}" \
19+
--region [AWS_REGION]
20+
21+
2 - ErrProcessPayment
22+
-------------------------
23+
aws stepfunctions start-execution \
24+
--state-machine-arn "arn:aws:states:[REGION]:[ACCOUNT NUMBER]:stateMachine:[STATEMACHINE-NAME]" \
25+
--input "{\"order_id\": \"20b0b599-441b-45c3-910e-ad63fe992c43\", \"order_date\": \"2018年10月19日T10:50:16+08:00\", \"customer_id\": \"151ae48f-79b0-47b6-a8a6-bd8dbcf9af9a\", \"items\": [{ \"item_id\": \"423\", \"qty\": 10.0, \"description\": \"Cart item 1\", \"unit_price\": 34.99 }]}" \
26+
--region [AWS_REGION]
27+
28+
22 - ErrProcessRefund
29+
-------------------------
30+
aws stepfunctions start-execution \
31+
--state-machine-arn "arn:aws:states:[REGION]:[ACCOUNT NUMBER]:stateMachine:[STATEMACHINE-NAME]" \
32+
--input "{\"order_id\": \"222f741b-0292-4f93-a2f7-503f92486955 \", \"order_date\": \"2018年10月19日T10:50:16+08:00\", \"customer_id\": \"227dd3c9-58ab-4f0d-958a-5ead5858fba8\", \"items\": [{ \"item_id\": \"655\", \"qty\": 2.0, \"description\": \"Cart item 1\", \"unit_price\": 99.99 }]}" \
33+
--region [AWS_REGION]
34+
35+
3 - ErrReserveInventory
36+
-------------------------
37+
aws stepfunctions start-execution \
38+
--state-machine-arn "arn:aws:states:[REGION]:[ACCOUNT NUMBER]:stateMachine:[STATEMACHINE-NAME]" \
39+
--input "{\"order_id\": \"3a7dc768-6f32-495d-a140-3d330c246f50\", \"order_date\": \"2018年10月19日T10:50:16+08:00\", \"customer_id\": \"aa226136-bd50-4718-8e87-6962c8d34779\", \"items\": [{ \"item_id\": \"765\", \"qty\": 1.0, \"description\": \"Cart item 1\", \"unit_price\": 6.50 }]}" \
40+
--region [AWS_REGION]
41+
42+
33 - ErrReleaseInventory
43+
-------------------------
44+
aws stepfunctions start-execution \
45+
--state-machine-arn "arn:aws:states:[REGION]:[ACCOUNT NUMBER]:stateMachine:[STATEMACHINE-NAME]" \
46+
--input "{\"order_id\": \"33a49007-a815-4079-9b9b-e30ae7eca11f\", \"order_date\": \"2018年10月19日T10:50:16+08:00\", \"customer_id\": \"39081ebf-16a9-4e2c-a88b-d1a4c76956fd\", \"items\": [{ \"item_id\": \"567\", \"qty\": 1.0, \"description\": \"Cart item 1\", \"unit_price\": 199.99 }]}" \
47+
--region [AWS_REGION]
48+
49+
4 to 9 - No error
50+
-------------------------
51+
aws stepfunctions start-execution \
52+
--state-machine-arn "arn:aws:states:[REGION]:[ACCOUNT NUMBER]:stateMachine:[STATEMACHINE-NAME]" \
53+
--input "{\"order_id\": \"47063fe3-56d9-4c51-b91f-71929834ce03\", \"order_date\": \"2018年10月19日T10:50:16+08:00\", \"customer_id\": \"3b27c7c4-7a3e-4635-aef9-6b5c74de6465\", \"items\": [{ \"item_id\": \"988\", \"qty\": 100.0, \"description\": \"Cart item 1\", \"unit_price\": 0.99 }]}" \
54+
--region [AWS_REGION]

‎docs/guide.md‎

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ Any state can encounter runtime errors. Errors can arise because of state machin
5757
```json
5858
"Catch": [
5959
{
60-
"ErrorEquals": ["ErrProcessOrder"],
61-
"ResultPath": "$.error",
62-
"Next": "UpdateOrderStatus"
60+
"ErrorEquals": ["ErrProcessOrder"],
61+
"ResultPath": "$.error",
62+
"Next": "UpdateOrderStatus"
6363
}
6464
]
6565
```
@@ -84,7 +84,32 @@ When a state reports an error, the interpreter scans through the Retriers and, w
8484
]
8585
```
8686

87-
## Invoking your Step Function via CLI
87+
## Custom Errors
88+
89+
The following is a list of all the custom errors thrown by the application and can be used in your state machine.
90+
91+
* `ErrProcessOrder` represents a process order error
92+
* `ErrUpdateOrderStatus` represents a process order error
93+
* `ErrProcessPayment` represents a process payment error
94+
* `ErrProcessRefund` represents a process payment refund error
95+
* `ErrReserveInventory` represents a inventory update error
96+
* `ErrReleaseInventory` represents a inventory update reversal error
97+
98+
## Testing Scenarios
99+
100+
The AWS Step Functions implementation has been configured for you to be easily test the various scenarios of the saga implementation. Modifying your `order_id` with a specified prefix will trigger an error in the each Task.
101+
102+
OrderID Prefix | Will error with | Example | Expected execution
103+
------------ | ------------- | --- | ---
104+
1 | ErrProcessOrder | 1ae4501d-ed92-4b27-bf0e-fd978ed45127 | ![1](images/paths-breakdown-1.png)
105+
11 | ErrUpdateOrderStatus | 11328abd-368d-43fd-bd4f-db15b5b63951 | ![11](images/paths-breakdown-11.png)
106+
2 | ErrProcessPayment | 20b0b599-441b-45c3-910e-ad63fe992c43 | ![2](images/paths-breakdown-2.png)
107+
22 | ErrProcessRefund | 222f741b-0292-4f93-a2f7-503f92486955 | ![22](images/paths-breakdown-22.png)
108+
3 | ErrReserveInventory | 3a7dc768-6f32-495d-a140-3d330c246f50 | ![3](images/paths-breakdown-3.png)
109+
33 | ErrReleaseInventory | 33a49007-a815-4079-9b9b-e30ae7eca11f | ![3](images/paths-breakdown-33.png)
110+
4-9 | No error | 47063fe3-56d9-4c51-b91f-71929834ce03 | ![4-9](images/paths-breakdown-7.png)
111+
112+
### Invoking your Step Function via CLI
88113

89114
The AWS CLI command will trigger a execution of your state machine. Make sure you substitute the ARN for the state machine in your account. You can find the ARN in the AWS CloudFormation Output section or in the AWS Step Functions console.
90115

@@ -95,47 +120,20 @@ The AWS CLI command will trigger a execution of your state machine. Make sure yo
95120
``` bash
96121
aws stepfunctions start-execution \
97122
--state-machine-arn "arn:aws:states:[REGION]:[ACCOUNT NUMBER]:stateMachine:[STATEMACHINE-NAME]" \
98-
--input "{\"order_id\": \"40063fe3-56d9-4c51-b91f-71929834ce03\", \"order_date\": \"2018年10月19日T10:50:16+08:00\", \"customer_id\": \"8d04ea6f-c6b2-4422-8550-839a16f01feb\", \"items\": [{ \"item_id\": \"567\", \"qty\": 1.0, \"description\": \"Cart item 1\", \"unit_price\": 199.99 }]}" \
123+
--input "{\"order_id\": \"40063fe3-56d9-4c51-b91f-71929834ce03\", \"order_date\": \"2018年10月19日T10:50:16+08:00\", \"customer_id\": \"8d04ea6f-c6b2-4422-8550-839a16f01feb\", \"items\": [{ \"item_id\": \"567\", \"qty\": 1.0, \"description\": \"Cart item 1\", \"unit_price\": 199.99 }]}" \
99124
--region [AWS_REGION]
100125
```
101126

102-
## Exceptions
103-
104-
The following is a list of all the exceptions thrown by the application and can be used in your state machine.
127+
[DOWNLOAD SCENARIO CLI COMMANDS](cli-commands.txt)
105128

106-
* **ErrProcessOrder** represents a process order error
107-
* **ErrUpdateOrderStatus** represents a process order error
108-
* **ErrProcessPayment** represents a process payment error
109-
* **ErrProcessRefund** represents a process payment refund error
110-
* **ErrReserveInventory** represents a inventory update error
111-
* **ErrReleaseInventory** represents a inventory update reversal error
112-
113-
## Testing Scenarios
114-
115-
The AWS Step Functions implementation has been configured for you to be easily test the various scenarios of the saga implementation. Modifying your `order_id` with a specified prefix will trigger an error in the each Task.
116-
117-
OrderID Prefix | Will error with | Example | Expected execution
118-
------------ | ------------- | --- | ---
119-
1 | ErrProcessOrder | <pre>--input "{\"order_id\": \"1ae4501d-ed92-4b27-bf0e-fd978ed45127\",<br/>\"order_date\": \"2018年10月19日T10:50:16+08:00\", <br/>\"customer_id\": \"0d52eeef-52a1-4e6e-a5b1-d0515121306c\", <br/>\"items\": [{ \"item_id\": \"929\", \"qty\": 3.0, <br/>\"description\": \"Cart item 1\", \"unit_price\": 9.99}]}"</pre> | ![1](images/paths-breakdown-1.png)
120-
11 | ErrUpdateOrderStatus | <pre>--input "{\"order_id\": \"11328abd-368d-43fd-bd4f-db15b5b63951\", <br/>\"order_date\": \"2018年10月19日T10:50:16+08:00\", <br/>\"customer_id\": \"8d04ea6f-c6b2-4422-8550-839a16f01feb\", <br/>\"items\": [{ \"item_id\": \"567\", \"qty\": 1.0, <br/>\"description\": \"Cart item 1\", \"unit_price\": 199.99}]}"</pre> | ![11](images/paths-breakdown-11.png)
121-
2 | ErrProcessPayment | <pre>--input "{\"order_id\": \"20b0b599-441b-45c3-910e-ad63fe992c43\", <br/>\"order_date\": \"2018年10月19日T10:50:16+08:00\", <br/>\"customer_id\": \"151ae48f-79b0-47b6-a8a6-bd8dbcf9af9a\", <br/>\"items\": [{ \"item_id\": \"423\", \"qty\": 10.0, <br/>\"description\": \"Cart item 1\", \"unit_price\": 34.99}]}"</pre> | ![2](images/paths-breakdown-2.png)
122-
22 | ErrProcessRefund | <pre>--input "{\"order_id\": \"222f741b-0292-4f93-a2f7-503f92486955 \", <br/>\"order_date\": \"2018年10月19日T10:50:16+08:00\", <br/>\"customer_id\": \"227dd3c9-58ab-4f0d-958a-5ead5858fba8\", <br/>\"items\": [{ \"item_id\": \"655\", \"qty\": 2.0, <br/>\"description\": \"Cart item 1\", \"unit_price\": 99.99}]}"</pre>| ![22](images/paths-breakdown-22.png)
123-
3 | ErrReserveInventory | <pre>--input "{\"order_id\": \"3a7dc768-6f32-495d-a140-3d330c246f50\", <br/>\"order_date\": \"2018年10月19日T10:50:16+08:00\", <br/>\"customer_id\": \"aa226136-bd50-4718-8e87-6962c8d34779\", <br/>\"items\": [{ \"item_id\": \"765\", \"qty\": 1.0, <br/>\"description\": \"Cart item 1\", \"unit_price\": 6.50}]}"</pre> | ![3](images/paths-breakdown-3.png)
124-
33 | ErrReleaseInventory | <pre>--input "{\"order_id\": \"33a49007-a815-4079-9b9b-e30ae7eca11f\", <br/>\"order_date\": \"2018年10月19日T10:50:16+08:00\", <br/>\"customer_id\": \"39081ebf-16a9-4e2c-a88b-d1a4c76956fd\", <br/>\"items\": [{ \"item_id\": \"567\", \"qty\": 1.0, <br/>\"description\": \"Cart item 1\", \"unit_price\": 199.99}]}"</pre> | ![3](images/paths-breakdown-33.png)
125-
4-9 | No error | <pre>--input "{\"order_id\": \"47063fe3-56d9-4c51-b91f-71929834ce03\", <br/>\"order_date\": \"2018年10月19日T10:50:16+08:00\", <br/>\"customer_id\": \"3b27c7c4-7a3e-4635-aef9-6b5c74de6465\", <br/>\"items\": [{ \"item_id\": \"988\", \"qty\": 100.0, <br/>\"description\": \"Cart item 1\", \"unit_price\": 0.99}]}"</pre> | ![4-9](images/paths-breakdown-7.png)
126-
127-
128-
## Additional Resources
129-
130-
### Step Functions
129+
## Additional Step Functions Resources
131130

132131
* [AWS Step Functions](https://aws.amazon.com/step-functions/)
133132
* [AWS Step Functions Developer Guide](https://docs.aws.amazon.com/step-functions/latest/dg/welcome.html)
134133
* [AWS Step Function Tutorials](https://docs.aws.amazon.com/step-functions/latest/dg/tutorials.html)
135134
* [statelint](https://github.com/awslabs/statelint)
136135
* [Amazon States Language](https://states-language.net/spec.html)
137136

138-
139137
## How else can you implement this solution?
140138

141139
Is there any other way you can think of how to break this problem down? What other features of Step Functions could be employed to implement a saga pattern?

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /