Durable.Executor (Durable v0.1.0-rc)

View Source

The main workflow executor.

Responsible for:

  • Starting new workflow executions
  • Executing workflow steps sequentially
  • Managing workflow state and context
  • Handling workflow suspension and resumption

Summary

Functions

cancel_workflow(workflow_id, reason \\ nil, opts \\ [])

@spec cancel_workflow(String.t(), String.t() | nil, keyword()) ::
  :ok | {:error, term()}

Cancels a running or pending workflow.

execute_workflow(workflow_id, config)

@spec execute_workflow(String.t(), Durable.Config.t()) ::
  {:ok, map()} | {:waiting, map()} | {:error, term()}

Executes a workflow by ID.

This is called internally by queue workers or directly for immediate execution.

resume_workflow(workflow_id, additional_context \\ %{}, opts \\ [])

@spec resume_workflow(String.t(), map(), keyword()) ::
  {:ok, String.t()} | {:error, term()}

Resumes a waiting workflow.

Options

  • :inline - If true, execute synchronously instead of via queue (default: false)
  • :durable - The Durable instance name (default: Durable)

start_workflow(module, input, opts \\ [])

@spec start_workflow(module(), map(), keyword()) ::
  {:ok, String.t()} | {:error, term()}

Starts a new workflow execution.

Options

  • :workflow - The workflow name (optional, uses default if not specified)
  • :queue - The queue to use (default: "default")
  • :priority - Priority level (default: 0)
  • :scheduled_at - Schedule for future execution
  • :durable - The Durable instance name (default: Durable)

Returns

  • {:ok, workflow_id} on success
  • {:error, reason} on failure