Durable.Config (Durable v2.0.2)
View SourceConfiguration management for Durable.
Durable configuration is validated at startup and stored in persistent_term for fast runtime access.
Options
:repo- The Ecto repo module to use for persistence (required):name- Instance name for multiple Durable instances (default:Durable):prefix- PostgreSQL schema name. Only"durable"is supported for now: the schemas are bound to it, so another value would write runs to one schema and poll for them in another.:queues- Queue configuration map (default:%{default: [concurrency: 10, poll_interval: 1000]}).concurrencyis per node.poll_intervalis how often an idle queue checks for work, in milliseconds. With a:pubsub, a start or resume wakes the queue's pollers at once, on every node in the cluster, so a long interval only delays runs that come due later: sleeps, retries, snoozes and delayed starts. Both are positive integers, and a queue takes nothing else: a queue that could never claim, or a misspelt option, is refused when Durable starts, with an error naming the queue.:pubsub- Phoenix.PubSub for lifecycle broadcasts and waking pollers: a server name,:startfor Durable's own, ornil(default). A start inside your own transaction wakes them when it commits. Without a PubSub, runs are claimed on the next poll:queue_enabled- Enable/disable queue processing (default:true):stale_lock_timeout- Seconds before a lock is considered stale (default:300):heartbeat_interval- Milliseconds between worker heartbeats (default:30_000):shutdown_grace_period- Milliseconds a stopping node waits for its running steps, with no new claims (default:15_000). Each run finishes its current step, then goes back on its queue for another node. Keep your platform's shutdown limit longer than this. A step still running then is killed, and its run goes back on its queue. At0the node doesn't wait: every run it has goes back on its queue at once:log_level- Log level for Ecto queries, orfalseto disable (default:false)
Examples
# Single instance (most common)
{Durable, repo: MyApp.Repo}
# With custom queues
{Durable,
repo: MyApp.Repo,
queues: %{
default: [concurrency: 10],
high_priority: [concurrency: 20, poll_interval: 500]
}}
Summary
Functions
Removes the configuration for a Durable instance.
Retrieves the configuration for a Durable instance.
Retrieves the configuration, returning nil if not set.
Gets the heartbeat interval for a Durable instance.
Creates a new validated configuration from options.
Creates a new validated configuration, raising on error.
Gets the database prefix for a Durable instance.
Stores the configuration for a Durable instance.
Checks if queue processing is enabled for a Durable instance.
Gets the queues configuration for a Durable instance.
Gets the repo module for a Durable instance.
Returns the NimbleOptions schema for documentation.
Gets the stale lock timeout for a Durable instance.
Returns the Task.Supervisor name for a Durable instance.
Types
@type t() :: %Durable.Config{ heartbeat_interval: pos_integer(), log_level: false | :debug | :info | :warning | :error, name: atom(), node_id: String.t() | nil, owns_pubsub?: boolean(), prefix: String.t(), prune: keyword() | nil, pubsub: atom() | nil, queue_enabled: boolean(), queues: map(), repo: module(), scheduled_modules: [module()], scheduler_interval: pos_integer(), shutdown_grace_period: non_neg_integer(), sleep_waker_batch_size: pos_integer(), sleep_waker_interval: pos_integer(), stale_lock_timeout: pos_integer() }
Functions
@spec delete(atom()) :: :ok
Removes the configuration for a Durable instance.
Retrieves the configuration for a Durable instance.
Raises if the configuration hasn't been set.
Retrieves the configuration, returning nil if not set.
@spec heartbeat_interval(atom()) :: pos_integer()
Gets the heartbeat interval for a Durable instance.
@spec new(keyword()) :: {:ok, t()} | {:error, NimbleOptions.ValidationError.t()}
Creates a new validated configuration from options.
Returns {:ok, config} if valid, {:error, reason} otherwise.
Respects the :durable app env key :disable_queue_processing. When
set to true, it forces queue_enabled: false regardless of the
user's opts. Mix tasks set this before booting the host app so they
don't accidentally claim jobs they can't finish.
Creates a new validated configuration, raising on error.
Gets the database prefix for a Durable instance.
Stores the configuration for a Durable instance.
Configuration is stored in persistent_term for fast lookups.
Checks if queue processing is enabled for a Durable instance.
Gets the queues configuration for a Durable instance.
Gets the repo module for a Durable instance.
@spec schema() :: keyword()
Returns the NimbleOptions schema for documentation.
@spec stale_lock_timeout(atom()) :: pos_integer()
Gets the stale lock timeout for a Durable instance.
Returns the Task.Supervisor name for a Durable instance.
This supervisor is used for parallel step execution.