Durable.Supervisor (Durable v0.1.0-rc)

View Source

The main supervisor for a Durable instance.

This supervisor manages the queue system for processing workflows. Users add Durable to their application's supervision tree to start the workflow engine.

Usage

Add Durable to your application's supervision tree:

defmodule MyApp.Application do
  use Application

  def start(_type, _args) do
    children = [
      MyApp.Repo,
      {Durable, repo: MyApp.Repo}
    ]

    opts = [strategy: :one_for_one, name: MyApp.Supervisor]
    Supervisor.start_link(children, opts)
  end
end

Options

See Durable.Config for available options.

Multiple Instances

You can run multiple Durable instances by giving each a unique name:

children = [
  MyApp.Repo,
  {Durable, repo: MyApp.Repo, name: :workflows_a, prefix: "durable_a"},
  {Durable, repo: MyApp.Repo, name: :workflows_b, prefix: "durable_b"}
]

Each instance has its own:

  • Configuration stored separately
  • Queue system (pollers, workers)
  • Database tables (when using different prefixes)

Summary

Functions

Returns a specification to start this module under a supervisor.

Starts the Durable supervisor.

Stops a Durable instance and cleans up its configuration.

Returns the supervisor name for a Durable instance.

Returns the Task.Supervisor name for a Durable instance.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts)

@spec start_link(keyword()) :: Supervisor.on_start()

Starts the Durable supervisor.

Options

  • :repo - The Ecto repo module (required)
  • :name - Instance name (default: Durable)
  • :prefix - Database schema prefix (default: "durable")
  • :queues - Queue configuration
  • :queue_enabled - Enable/disable queue processing (default: true)

See Durable.Config for the complete list of options.

stop(name \\ Durable)

@spec stop(atom()) :: :ok

Stops a Durable instance and cleans up its configuration.

supervisor_name(name)

@spec supervisor_name(atom()) :: atom()

Returns the supervisor name for a Durable instance.

task_supervisor_name(name)

@spec task_supervisor_name(atom()) :: atom()

Returns the Task.Supervisor name for a Durable instance.