Zenaton white logo

Examples

We provide some examples ready to run (on the same machine where you already launched a Zenaton Agent)

git clone https://github.com/zenaton/examples-php.git
git clone https://github.com/zenaton/examples-node.git
git clone https://github.com/zenaton/examples-ruby.git
git clone https://github.com/zenaton/examples-python.git

Executing Tasks Sequentially

You can dispatch tasks sequentially meaning that tasks will be distributed but execution is sequential.

This example showcases

The use of execute method to trigger a synchronous execution.

A distributed but sequential execution of 3 tasks.

Each task is executed only when the previous one is completed.

The output of the first task is used to decide what is the second task.

Sequential Workflow in Action

After launching your workflow, let's check the Zenaton dashboard to monitor our workflow. We can also click on each task to see the details and properties.

live monitoring sequential jobs

Executing Tasks in Parallel

You can dispatch tasks in parallel meaning that tasks will be distributed but execution is in parallel.

This example showcases

The simultaneous execution of first 2 tasks.

The last task is executed if and only if first two tasks are both completed.

Results of first 2 tasks are used to decide which last task will be executed.

Parallel Workflow in Action

After launching your workflow, let's have a look on the monitoring dashboard on Zenaton Interface. For more visibility, you can also click on each task to view its properties.

live monitoring parallel jobs

Executing Tasks Asynchronously

You can dispatch tasks asynchronously meaning that tasks will be distributed but execution is asynchronous.

This example showcases

The use of dispatch method to trigger an asynchronous execution (fire and forget).

Asynchronous execution of tasks A and B does not block execution flow.

Only the synchronous execution of task C delays execution of D.

Asynchronous Workflow in Action

After launching your workflow, let's have a look on the monitoring dashboard on Zenaton Interface. For more visibility, you can also click on each task to view its properties.

live monitoring asynchronous jobs

Reacting to External Events

You can also trigger tasks within a workflow based on external events.

TIME

This example showcases

The use of the onEvent method to react to external events.

How to send an event to a workflow.

How to use internal properties to change a workflow's behaviour through an external event

How Zenaton lets you easily code event-based workflows.

External Events Workflow in Action

After launching your workflow, let's have a look on the monitoring dashboard on Zenaton Interface. For more detail, you can also click on each task to view its properties.

live monitoring external events jobs

Waiting for a Date or a Duration

You can dispatch tasks and wait for a date or a duration meaning that tasks will be distributed but execution is at a precise date or time.

WAIT 5S

This example showcases

The use of the provided Wait class to manage time.

How to pause a workflow for a specified duration or date.

A lot of syntactic sugar is provided (eg. to wait for next monday at 8am) - check the complete documentationcheck the complete documentationcheck the complete documentationcheck the complete documentationcheck the complete documentation.

Waiting Workflow in Action

After launching your workflow, let's have a look at the dashboard. For more detail, you can also click on each task to view its properties.

live monitoring waiting date jobs

Waiting for External Events

You can dispatch tasks and wait for external events meaning that tasks will be distributed but execution is linked to external events.

TIME

This example showcases

The use of the provided Wait class to pause a workflow by waiting for an external event.

How you can add (optional) a time out when waiting an event.

How you can retrieve the sent event and use it in your workflow.

Waiting for External Events Workflow in Action

After launching your workflow, let's have a look at the dashboard. For more detail, you can also click on each task to view its properties.

live monitoring waiting event jobs