The only requirements to write a workflow are:
Zenaton.abstracts.workflow.Workflowclass that requires only a
handlemethod that will be called to run the workflow;
zenaton.traits.zenatonable.Zenatonableclass, that defines
Idempotence implies that any actions (such as requesting a database, writing/reading a file, using current time, sending an email, echoing in console, etc.) that have side effects or that need access to potentially changing information MUST be done within tasks (not from within workflows).
As Zenaton engine triggers the execution of the class describing a workflow each time it has to decide what to do next, failing to follow the idempotence requirement will lead to multiple executions of actions wrongly present in it.
The provided methods
dispatchare internally implemented to ensure idempotency.
from zenaton.abstracts.workflow import Workflow from zenaton.traits.zenatonable import Zenatonable class WelcomeFlow(Workflow, Zenatonable): def __init__(self, user): self.email = user.email self.slack_id = user.slack_id def handle(self): SendWelcomeEmail(self.email).execute() IntroduceUserThroughSlack(self.slack_id).execute()
You need to setup Zenaton with your credentials:
Zenaton.client.Client(app_id, api_token, app_env)
then launching a workflow is as easy as:
If you want to reference this workflow later, just implement a
public method in your workflow implementation that provides the id Zenaton should
use to retrieve this workflow instance, eg in
... def id(self) return self.email ...
To be valid, this
idmethod MUST be unique (meaning in the same environment, you can not have two running instances of the same workflow with the same id).
You can pause a workflow’s instance
and later resume it
or even kill it
It is also possible to pause, resume or kill worklows directly from Zenaton Interface.
At any time, you can inspect current properties by retrieving an instance by id:
If an error occurred during a task execution, then this workflow instance will automatically be paused and you will have to resume it manually here. You can also retry them manually directly from the interface.