Which Source Of Truth?


Data in workflows are not automatically synchronized with your databases. For example, if you provide a user object as input to a workflow:

User {
  id: "1234",
  email: "gilles@gmail.com",
}

You need to insure that email is up-to-date if it is used in this workflow two weeks later. Once injected as input, data in workflows can be updated:

  • through outputs of tasks
  • through data received with events

Two ways to update the email used in the workflow:

  • through a task that requests your database
  • sending an event "EmailUpdated" (with the email as event data), each time the email is updated in your app.

Its often a hassle to synchronize user data this way so the simplest approach may be to use Ids instead of data in workflows. The recommended approach is to make sure that there is only one source of truth, depending on the situation:

"Could this data change with time ?"

  • No => Use it in workflow

  • Yes => "Is this data already stored in my databases?"

    • No => Use the workflow as the source of truth, and maintain the data there
    • Yes => Use your database as the source of truth, use Ids in workflows and request the data when needed within tasks.

TIP

At any step of a workflow, you can add a task to record data in your databases. For example, if your need a longer data-retention than your Zenaton plan provides, it's always possible to record the resulting data to your database as the last step in a workflow.