feat: run nested async workflows (#9119)
This commit is contained in:
committed by
GitHub
parent
0bcdcccbe2
commit
ef8dc4087e
@@ -1,7 +1,9 @@
|
||||
import {
|
||||
StepResponse,
|
||||
WorkflowResponse,
|
||||
createStep,
|
||||
createWorkflow,
|
||||
parallelize,
|
||||
} from "@medusajs/workflows-sdk"
|
||||
import { setTimeout } from "timers/promises"
|
||||
|
||||
@@ -17,9 +19,9 @@ const step_1_background = createStep(
|
||||
})
|
||||
)
|
||||
|
||||
createWorkflow(
|
||||
const nestedWorkflow = createWorkflow(
|
||||
{
|
||||
name: "workflow_async_background",
|
||||
name: "nested_sub_flow_async",
|
||||
},
|
||||
function (input) {
|
||||
const resp = step_1_background(input)
|
||||
@@ -27,3 +29,25 @@ createWorkflow(
|
||||
return resp
|
||||
}
|
||||
)
|
||||
|
||||
createWorkflow(
|
||||
{
|
||||
name: "workflow_async_background",
|
||||
},
|
||||
function (input) {
|
||||
const [ret] = parallelize(
|
||||
nestedWorkflow
|
||||
.runAsStep({
|
||||
input,
|
||||
})
|
||||
.config({ name: "step_sub_flow_1" }),
|
||||
nestedWorkflow
|
||||
.runAsStep({
|
||||
input,
|
||||
})
|
||||
.config({ name: "step_sub_flow_2" })
|
||||
)
|
||||
|
||||
return new WorkflowResponse(ret)
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user