You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+49Lines changed: 49 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,6 +41,7 @@ This package lets you run AWS Step Functions state machines completely locally,
41
41
-[Overriding Task and Wait states](#overriding-task-and-wait-states)
42
42
-[Task state override](#task-state-override)
43
43
-[Wait state override](#wait-state-override)
44
+
-[Retry field pause override](#retry-field-pause-override)
44
45
-[Passing a custom Context Object](#passing-a-custom-context-object)
45
46
-[Disabling ASL validations](#disabling-asl-validations)
46
47
-[Exit codes](#exit-codes)
@@ -362,6 +363,54 @@ local-sfn \
362
363
363
364
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.
364
365
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:
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:
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
+
365
414
### Passing a custom Context Object
366
415
367
416
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:
'Usage: local-sfn [options] [inputs...]\n\nExecute an Amazon States Language state machine with the given inputs.\nThe result of each execution will be output in a new line and in the same order\nas its corresponding input.\n\nArguments:\n inputs Input data for the state machine, can be any\n valid JSON value. Each input represents a\n state machine execution.\n \n When reading from the standard input, if the\n first line can be parsed as a single JSON\n value, then each line will be considered as an\n input. Otherwise, the entire standard input\n will be considered as a single JSON input.\n\nOptions:\n -V, --version Print the version number and exit.\n -d, --definition <definition> A JSON definition of a state machine.\n -f, --definition-file <path> Path to a file containing a JSON state machine\n definition.\n -t, --override-task <mapping> Override a Task state to run an executable\n file or script, instead of calling the service\n specified in the \'Resource\' field of the state\n definition. The mapping value has to be\n provided in the format\n [TaskStateToOverride]:[path/to/override/script].\n The override script will be passed the input\n of the Task state as first argument, which can\n then be used to compute the task result. The\n script must print the task result as a JSON\n value to the standard output.\n -w, --override-wait <mapping> Override a Wait state to pause for the\n specified amount of milliseconds, instead of\n pausing for the duration specified in the\n state definition. The mapping value has to be\n provided in the format\n [WaitStateToOverride]:[number].\n --context <json> A JSON object that will be passed to each\n execution as the context object.\n --context-file <path> Path to a file containing a JSON object that\n will be passed to each execution as the\n context object.\n --no-jsonpath-validation Disable validation of JSONPath strings in the\n state machine definition.\n --no-arn-validation Disable validation of ARNs in the state\n machine definition.\n --no-validation Disable validation of the state machine\n definition entirely. Use this option at your\n own risk, there are no guarantees when passing\n an invalid or non-standard definition to the\n state machine. Running it might result in\n undefined/unsupported behavior.\n -h, --help Print help for command and exit.\n\nExit codes:\n 0 All executions ran successfully.\n 1 An error occurred before the state machine could be executed.\n 2 At least one execution had an error.\n\nExample calls:\n $ local-sfn -f state-machine.json \'{ "num1": 2, "num2": 2 }\'\n $ local-sfn -f state-machine.json -t SendRequest:./override.sh -w WaitResponse:2000 \'{ "num1": 2, "num2": 2 }\'\n $ cat inputs.txt | local-sfn -f state-machine.json\n'
37
+
'Usage: local-sfn [options] [inputs...]\n\nExecute an Amazon States Language state machine with the given inputs.\nThe result of each execution will be printed in a new line and in the same\norder as its corresponding input.\n\nArguments:\n inputs Input data for the state machine, can be any\n valid JSON value. Each input represents a\n state machine execution.\n \n When reading from the standard input, if the\n first line can be parsed as a single JSON\n value, then each line will be considered as\n an input. Otherwise, the entire standard\n input will be considered as a single JSON\n input.\n\nOptions:\n -V, --version Print the version number and exit.\n -d, --definition <definition> A JSON definition of a state machine.\n -f, --definition-file <path> Path to a file containing a JSON state\n machine definition.\n -t, --override-task <mapping> Override a Task state to run an executable\n file or script, instead of calling the\n service specified in the \'Resource\' field of\n the state definition. The mapping value has\n to be provided in the format\n [TaskStateToOverride]:[path/to/override/script].\n The override script will be passed the input\n of the Task state as first argument, which\n can then be used to compute the task result.\n The script must print the task result as a\n JSON value to the standard output.\n -w, --override-wait <mapping> Override a Wait state to pause for the\n specified amount of milliseconds, instead of\n pausing for the duration specified in the\n state definition. The mapping value has to be\n provided in the format\n [WaitStateToOverride]:[number].\n -r, --override-retry <mapping> Override a \'Retry\' field to pause for the\n specified amount of milliseconds, instead of\n pausing for the duration specified by the\n retry policy. The mapping value has to be\n provided in the format\n [NameOfStateWithRetryField]:[number].\n --context <json> A JSON object that will be passed to each\n execution as the context object.\n --context-file <path> Path to a file containing a JSON object that\n will be passed to each execution as the\n context object.\n --no-jsonpath-validation Disable validation of JSONPath strings in the\n state machine definition.\n --no-arn-validation Disable validation of ARNs in the state\n machine definition.\n --no-validation Disable validation of the state machine\n definition entirely. Use this option at your\n own risk, there are no guarantees when\n passing an invalid or non-standard definition\n to the state machine. Running it might result\n in undefined/unsupported behavior.\n -h, --help Print help for command and exit.\n\nExit codes:\n 0 All executions ran successfully.\n 1 An error occurred before the state machine could be executed.\n 2 At least one execution had an error.\n\nExample calls:\n $ local-sfn -f state-machine.json \'{ "num1": 2, "num2": 2 }\'\n $ local-sfn -f state-machine.json -t SendRequest:./override.sh -w WaitResponse:2000 \'{ "num1": 2, "num2": 2 }\'\n $ cat inputs.txt | local-sfn -f state-machine.json\n'
Copy file name to clipboardExpand all lines: src/cli/CLI.ts
+8-1Lines changed: 8 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,7 @@ import {
10
10
parseInputArguments,
11
11
parseOverrideTaskOption,
12
12
parseOverrideWaitOption,
13
+
parseOverrideRetryOption,
13
14
parseContextOption,
14
15
parseContextFileOption,
15
16
}from'./ArgumentParsers';
@@ -23,7 +24,7 @@ function makeProgram() {
23
24
.name('local-sfn')
24
25
.description(
25
26
`Execute an Amazon States Language state machine with the given inputs.
26
-
The result of each execution will be output in a new line and in the same order as its corresponding input.`
27
+
The result of each execution will be printed in a new line and in the same order as its corresponding input.`
27
28
)
28
29
.helpOption('-h, --help','Print help for command and exit.')
29
30
.configureHelp({helpWidth: 80})
@@ -63,6 +64,12 @@ Example calls:
63
64
'Override a Wait state to pause for the specified amount of milliseconds, instead of pausing for the duration specified in the state definition. The mapping value has to be provided in the format [WaitStateToOverride]:[number].'
64
65
).argParser(parseOverrideWaitOption)
65
66
)
67
+
.addOption(
68
+
newOption(
69
+
'-r, --override-retry <mapping>',
70
+
"Override a 'Retry' field to pause for the specified amount of milliseconds, instead of pausing for the duration specified by the retry policy. The mapping value has to be provided in the format [NameOfStateWithRetryField]:[number]."
0 commit comments