Constraints On Workflow Implementation


# How it works

The Zenaton "secret sauce" is the ability to process the generator functions to process workflows as described:

  • despite that actions may fail,
  • despite that Agent processing tasks can be distributed,
  • despite that workflows can be long-running (weeks...etc)

When Zenaton processes the handle or onEvent function, it looks at each action and checks if it has already been seen:

  • if not, then Zenaton dispatches this action and
    • if the action is yielded, it stops there
    • if the action is not yielded, it continues
  • if yes,
    • if the action is yielded:
      • if the action is completed, it injects the output and continues
      • if not, it stops there
    • if the action is not yielded, it continues

This process is repeated each time the workflow needs to know what to do next. Zenaton stores the complete history of all action processings as well as all updated properties. That way, if an error occurs somewhere, Zenaton is able to retry the failed action and resume the workflow.

# Implementation Constraints

DANGER

Due to the way workflows are processed (see above), workflows implementation MUST be idempotent. In more practical terms, it means it must implement only a logical flow and avoid all side-effects or non-deterministic processings.

Therefore avoid the following actions when writing workflows:

  • request a database (it may change with time)
  • access a file (it may change with time)
  • use environment variables (may change with time)
  • use now() (it will change each time)
  • use random functions (it will change each time)
  • use any promise (it may generate race conditions)
  • infinite loop (would force Zenaton to store an infinite history)
  • try / catch

All of these actions can and must be implemented within tasks.

Of course, all actions that Zenaton provides are internally implemented to ensure idempotency and can be used in workflows.

# Reserved Keywords

The following keywords should not be used as properties, as they are already used as functions or variables:

Zenaton functions:

  • this.run
  • this.wait
  • this.schedule
  • this.send()
  • this.pause()
  • this.resume()
  • this.terminate()
  • this.select
  • this.connector() (deprecated)

Helpers:

  • this.date() - to retrieve the current date from a workflow
  • this.log() - to log in zenaton.out from a workflow
  • this.random() - to get a random number from a workflow
  • this.context - provide a context to a decision