SquidMesh.Workflow (squid_mesh v0.1.0-alpha.3)

Copy Markdown View Source

Declarative workflow contract for Squid Mesh workflow modules.

Example

defmodule Billing.InvoiceReminder do
  use SquidMesh.Workflow

  workflow do
    trigger :invoice_delivery do
      manual()

      payload do
        field :account_id, :string
        field :invoice_id, :string
      end
    end

    step :load_invoice, Billing.Steps.LoadInvoice
    step :send_email, Billing.Steps.SendReminderEmail, retry: [max_attempts: 3]

    transition :load_invoice, on: :ok, to: :send_email
  end
end

The contract defined here captures workflow structure. Validation and runtime execution behavior are added in subsequent slices.

Summary

Functions

Declares a first-class approval step for manual review decisions.

Declares a cron-based trigger.

Declares one payload field inside a trigger payload block.

Declares a manual trigger.

Declares a manual review step as an alias of approval_step/2.

Declares the payload contract for the current trigger.

Declares one workflow step.

Declares a transition from one step outcome to the next step.

Declares a named workflow trigger.

Declares the workflow body.

Functions

approval_step(name, opts \\ [])

(macro)

Declares a first-class approval step for manual review decisions.

cron(expression, opts \\ [])

(macro)

Declares a cron-based trigger.

field(name, type, opts \\ [])

(macro)

Declares one payload field inside a trigger payload block.

manual()

(macro)

Declares a manual trigger.

manual_review_step(name, opts \\ [])

(macro)

Declares a manual review step as an alias of approval_step/2.

payload(list)

(macro)

Declares the payload contract for the current trigger.

step(name, module, opts \\ [])

(macro)

Declares one workflow step.

transition(from, opts)

(macro)

Declares a transition from one step outcome to the next step.

trigger(name, list)

(macro)

Declares a named workflow trigger.

workflow(list)

(macro)

Declares the workflow body.