Skip to content

Commit ac8b24a

Browse files
committed
Add section on how to override retry pause with CLI option
1 parent 1568e76 commit ac8b24a

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ This package lets you run AWS Step Functions state machines completely locally,
4141
- [Overriding Task and Wait states](#overriding-task-and-wait-states)
4242
- [Task state override](#task-state-override)
4343
- [Wait state override](#wait-state-override)
44+
- [Retry field pause override](#retry-field-pause-override)
4445
- [Passing a custom Context Object](#passing-a-custom-context-object)
4546
- [Disabling ASL validations](#disabling-asl-validations)
4647
- [Exit codes](#exit-codes)
@@ -362,6 +363,54 @@ local-sfn \
362363

363364
This command would execute the state machine, and override `Wait` states `WaitResponse` and `PauseUntilSignal` to pause the execution for 1500 and 250 milliseconds, respectively. The `Delay` state wouldn't be paused at all, since the override value is set to 0.
364365

366+
#### Retry field pause override
367+
368+
To override the duration of the pause in the `Retry` field of a state, pass the `-r, --override-retry` option. This option takes as value the name of the state whose `Retry` field you want to override, and a number that represents the amount in milliseconds that you want to pause the execution for before retrying the state. The state name and the milliseconds amount must be separated by a colon `:`.
369+
370+
For example, suppose the state machine definition contains a state called `TaskToRetry` that is defined as follows:
371+
372+
```json
373+
{
374+
"Type": "Task",
375+
"Resource": "arn:aws:lambda:us-east-1:123456789012:function:HelloWorld",
376+
"Retry": [
377+
{ "ErrorEquals": ["States.Timeout", "SyntaxError"] },
378+
{ "ErrorEquals": ["RangeError"] },
379+
{ "ErrorEquals": ["States.ALL"] }
380+
],
381+
"End": true
382+
}
383+
```
384+
385+
Then, the following command is run:
386+
387+
```sh
388+
local-sfn -f state-machine.json -r TaskToRetry:100 '{ "num1": 1, "num2": 2 }'
389+
```
390+
391+
This command would execute the state machine, and if the `TaskToRetry` state fails, the execution would be paused for 100 milliseconds before retrying the state again, disregarding the `IntervalSeconds`, `BackoffRate`, `MaxDelaySeconds`, and `JitterStrategy` fields that could've been specified in any of the `Retry` field retriers.
392+
393+
Alternatively, you can also pass a list of comma-separated numbers as value, to override the duration of specific retriers, for instance:
394+
395+
```sh
396+
local-sfn -f state-machine.json -r TaskToRetry:100,-1,20 '{ "num1": 1, "num2": 2 }'
397+
```
398+
399+
The above command would pause the execution for 100 milliseconds if the state error is matched by the first retrier and it would pause for 20 milliseconds if the error matches the third retrier. Note that a -1 was passed for the second retrier. This means that the pause duration of the second retrier will not be overridden, instead, it will be calculated as usually with the `IntervalSeconds` and the other retrier fields, or use the default values if said fields are not specified.
400+
401+
Furthermore, you can pass this option multiple times, to override the `Retry` fields in multiple states. For example:
402+
403+
```sh
404+
local-sfn \
405+
-f state-machine.json \
406+
-r SendRequest:1500 \
407+
-r ProcessData:250 \
408+
-r MapResponses:0 \
409+
'{ "num1": 1, "num2": 2 }'
410+
```
411+
412+
This command would execute the state machine, and override the duration of the retry pause in states `SendRequest` and `ProcessData` to pause the execution for 1500 and 250 milliseconds, respectively. The retry in the `MapResponses` state wouldn't be paused at all, since the override value is set to 0.
413+
365414
### Passing a custom Context Object
366415

367416
If the JSONPaths in your definition reference the Context Object, you can provide a mock Context Object by passing either the `--context` or the `--context-file` option. For example, given the following definition:

0 commit comments

Comments
 (0)