Git Product home page Git Product logo

order-workflow's Introduction

order-workflow

Simple proof of concept illustrating the use of SWF with node.js and the node-usher library.

See:

Components

  • activities.js - polls SWF for and executes activity tasks
  • decisions.js - polls SWF for and executes decision tasks
  • server.js - exposes a single http GET method to trigger a workflow

Prerequesites

The activity task names, decision task names, workflow name, versions and domain are hard coded. Its a POC. These resources need to exist before running this example.

  • swf domain: karl-test-swf-domain
  • workflow types:
    • example-order-manager
  • activity types:
    • test-begin-order
    • test-check-shipping
    • test-check-stock
    • test-process-payment
    • test-ship-order

All versions are 1.0.0

Running a Workflow

To start the server

$ docker-compose up order-wfm

To start the activity poller

$ docker-compose run order-wfm nodemon activities.js 

To start the decision poller

$ docker-compose run order-wfm nodemon decisions.js

To trigger a workflow:

$ curl localhost:8080/wf/start/12345
{"message":"Workflow started","productId":"12345","runId":"22ZtdCrDKFQLRl5CSnsMv5qDSuRnywBApAyc6eXawkOk8=","worflowId":"18293494323025428"}

Open Issues

Initial Decision Timeout

Occasionally there is a delay between starting a workflow and the execution of the first task. Inspecting the event history in this case shows that the first decision task times out. Another decision task is then scheduled and runs. The rest of the workflow completes without delay. This behavior is observed intermittently. It is not clear what causes this - my internet connection, the use of nodemon, a bug in node-usher, the swf service itself, etc.

Error and timeout handling

Programatically failing a task and letting SWF know whether or not the task should be retried is straightforward.

The following aspects of workflow management, at least within the node-usher API, is not clear:

  • being notified of a workflow's failure along with the context of the failed execution. The decision poller will log when a workflow execution fails, but it's not clear if there is a hook provided to take action in this case or whether or not the context of the failed workflow execution is provided.
  • being notified of an activity task timeout. It's not clear if the deicsion poller gets notified of this type of event and provides a means to take action.

AWS node.js client

If either of the open issues are important and not easily solved for with the node-usher api it is likely they can be handled with an additional integration with SWF using the AWS node.js client.

order-workflow's People

Contributors

kkastan avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.