Stated workflow can be run in a containerized environment and provide a REST API to manage the workflow.
List all running workflows. Start, stop and view workflows.
Fetch workflow's latest snapshot and restore the workflow from the snapshot.
This API can be used to send an event to the workflow dispatcher. The event will be dispatched to the subscriber of the given type.
node stated-workflow-api
Build image - the below command in docker should work for both amd64 and arm64 platforms
V=0.0.1 && docker buildx build --platform linux/amd64 . --tag sesergee773/statedworkflow:$V
Run it in your docker
docker run -d -it -p 8080:8080 sesergee773/statedworkflow:$V
# submit a workflow template
workflowId=`curl -H 'Content-Type:application/json' http://localhost:8080/workflow -X POST -d @example/joinResistanceRecovery.json | jq -r '.workflowId'` && echo $workflowId || echo failed to start the workflow: $!
# list all workflows
curl -H 'Content-Type:application/json' http://localhost:8080/workflow | jq
# get te workflow output
curl -H 'Content-Type:application/json' http://localhost:8080/workflow/$workflowId | jq
# stop the workflow
curl -H 'Content-Type:application/json' http://localhost:8080/workflow/$workflowId -X DELETE | jq
# show the latest workflow snapshot
curl -H 'Content-Type:application/json' http://localhost:8080/restore/$workflowId | jq
# restore the workflow from the latest snapshot
curl -H 'Content-Type:application/json' http://localhost:8080/restore/$workflowId -X POST | jq
# send an event with rebel named "obi" to the workflow dispatcher for "rebelDispatch" type and "rebelArmy" subscriber
curl -H 'Content-Type: application/json' http://localhost:8080/workflow/${workflowId}/rebelDispatch/rebelArmy -X POST -d '["obi"]'