feat(workflows-sdk): Configurable retries upon step creation (#5728)
**What**
- Allow to create step that can be configured to have a max retry
- Step end retry mechanism on permanent failure
Also added an API to override a step configuration from within the createWorkflow
```ts
const step = createStep({ name: "step", maxRetries: 3 }, async (_, context) => {
return new StepResponse({ output: "output" })
})
const workflow = createWorkflow("workflow", function () {
const res = step().config({ maxRetries: 5 }) // This will override the original maxRetries of 3
})
```
**NOTE**
We can maybe find another name than config on the step workflow data to override the step config.
This commit is contained in:
committed by
GitHub
parent
1a2f513d53
commit
9cc787cac4
@@ -10,7 +10,7 @@ import { Context, LoadedModule, MedusaContainer } from "@medusajs/types"
|
||||
import { MedusaModule } from "@medusajs/modules-sdk"
|
||||
import { EOL } from "os"
|
||||
import { ulid } from "ulid"
|
||||
import { SymbolWorkflowWorkflowData } from "../utils/composer"
|
||||
import { OrchestrationUtils } from "@medusajs/utils"
|
||||
|
||||
export type FlowRunOptions<TData = unknown> = {
|
||||
input?: TData
|
||||
@@ -99,11 +99,16 @@ export const exportWorkflow = <TData = unknown, TResult = unknown>(
|
||||
if (Array.isArray(resultFrom)) {
|
||||
result = resultFrom.map((from) => {
|
||||
const res = transaction.getContext().invoke?.[from]
|
||||
return res?.__type === SymbolWorkflowWorkflowData ? res.output : res
|
||||
return res?.__type === OrchestrationUtils.SymbolWorkflowWorkflowData
|
||||
? res.output
|
||||
: res
|
||||
})
|
||||
} else {
|
||||
const res = transaction.getContext().invoke?.[resultFrom]
|
||||
result = res?.__type === SymbolWorkflowWorkflowData ? res.output : res
|
||||
result =
|
||||
res?.__type === OrchestrationUtils.SymbolWorkflowWorkflowData
|
||||
? res.output
|
||||
: res
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user