Skip to content

Latest commit

 

History

History
75 lines (61 loc) · 2.31 KB

README.API.md

File metadata and controls

75 lines (61 loc) · 2.31 KB

Workflow Management API

Stated workflow can be run in a containerized environment and provide a REST API to manage the workflow.

/workflow APIs

List all running workflows. Start, stop and view workflows.

/restore APIs

Fetch workflow's latest snapshot and restore the workflow from the snapshot.

/workflow/{workflowId}/{type}/{subscriber} APIs

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.

Getting Started

Run locally

node stated-workflow-api

Run in Docker

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

API Examples

# 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"]'