feat(orchestration,workflows-sdk,core-flows): workflow cancel (#6778)

This commit is contained in:
Carlos R. L. Rodrigues
2024-03-22 11:03:06 -03:00
committed by GitHub
parent 3e85f4dd93
commit 7e93eda1a4
9 changed files with 271 additions and 22 deletions
@@ -16,10 +16,20 @@ interface StepInput {
export const updateTaxLinesStepId = "update-tax-lines-step"
export const updateTaxLinesStep = createStep(
updateTaxLinesStepId,
async (input: StepInput, { container }) => {
// TODO: manually trigger rollback on workflow when step fails
await updateTaxLinesWorkflow(container).run({ input })
async (input: StepInput, { container, idempotencyKey }) => {
const { transaction } = await updateTaxLinesWorkflow(container).run({
input,
})
return new StepResponse(null)
return new StepResponse(null, { transaction })
},
async (flow, { container }) => {
if (!flow) {
return
}
await updateTaxLinesWorkflow(container).cancel({
transaction: flow.transaction,
})
}
)