Created
July 31, 2020 20:32
CDK State Machine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const STATUS = "$.status" | |
const RETRY_SECONDS = "$.retrySeconds" | |
const PENDING = "pending" | |
const PROGRESS = "in-progress" | |
const FAILED = "failed" | |
const COMPLETE = "complete" | |
const setPending = stepFunction.setStatus(this, props.table, PENDING); | |
const setProgress = stepFunction.setStatus(this, props.table, PROGRESS); | |
const setSuccess = stepFunction.setStatus(this, props.table, COMPLETE); | |
const setFailed = stepFunction.setStatus(this, props.table, FAILED); | |
const waitForNSeconds = this.waitTask("retry seconds", RETRY_SECONDS); | |
const definition = this.mapperTask() | |
.next(setPending) | |
.next(waitForNSeconds) | |
.next(setProgress) | |
.next(this.deliverTransactionTask()) | |
.next( | |
new sfn.Choice(this, "Delivery success?") | |
.when(sfn.Condition.stringEquals(STATUS, COMPLETE), setComplete) | |
.when(sfn.Condition.stringEquals(STATUS, FAILED), setFailed) | |
.otherwise(setPending) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment