Writing deciders

Jeremy Brown edited this page Apr 7, 2016 · 4 revisions


Decision tasks are sent to deciders in order for them to make decisions.

The decider is called for every new event in the workflow.

The goal of the decider, is to send back a list of decisions for every new decision task.

In some cases, this list can be empty (for example, if we are waiting for multiple activities to finish).


Here is a list of API methods available on the decisionTask passed to the workflow module :

Query the state of the workflow :

  • just_started() : returns true if no activity has been scheduled yet (workflow just started)
  • completed('step1') : returns true if the activityId 'step1' is completed
  • scheduled('step2') : returns true if the activityId 'step2' has been scheduled (even if it's completed, failed, timedout, ...)

Respond some decisions :

  • schedule({name: 'step1', activity: 'hello-activity' }) : schedule a new activity task. 'step1' will be used as the activityId. The second parameter can contain any SWF property (timeouts, tasklists, etc...)
    • name is required
    • activity can be String or an Object. Object example: activity: { name: 'myName', version: '1.0.0' }
  • waiting_for('step1','step2') : respond no decision, but assert that step1 and step2 can eventually finish. If not, throws an exception, which will result in a FailWorkflowExecution.
  • start_childworkflow: TODO
  • start_timer: TODO

Get the data :

  • workflow_input() : returns the string passed as "input" at workflow start
  • results('step1') : returns the result value of activity 'step1'

End workflow executions :

  • stop("finished !") : stops the workflow execution (CompleteWorkflowExecution)
  • fail("reason of failure") : stops the workflow execution (FailWorkflowExecution)