OTP supervision boundary for workers consuming one Absurd queue.
A pool validates its task catalog and the installed Absurd schema before it starts claiming. It owns an unnamed dynamic supervisor for temporary runners and one capacity-aware poller; the caller continues to own the Postgrex queryable.
Place the pool after that queryable in the host application's supervision tree:
children = [
{Postgrex, name: MyApp.AbsurdDB, database: "my_app"},
{Absurd.WorkerPool,
name: MyApp.AbsurdWorkers,
db: MyApp.AbsurdDB,
queue: "default",
tasks: [MyApp.SendEmail]}
]Runner processes are temporary. PostgreSQL, rather than OTP restart policy, decides whether interrupted durable work is retried.
Summary
Functions
Returns an OTP child specification keyed by the configured pool name.
Starts a validated worker pool.
Functions
@spec child_spec(keyword()) :: Supervisor.child_spec()
Returns an OTP child specification keyed by the configured pool name.
@spec start_link(keyword()) :: Supervisor.on_start()
Starts a validated worker pool.
Required options are:
:name- an OTP server name for the pool;:db- a caller-owned Postgrex queryable;:queue- the queue consumed by this pool;:tasks- task modules or anAbsurd.TaskCatalogbehaviour module.
Optional values are :concurrency (default 1), :batch_size (defaulting
to concurrency), :claim_timeout (120_000 milliseconds),
:poll_interval (250 milliseconds), :shutdown (30_000 milliseconds),
:worker_id (default hostname:os-pid), :hooks (Absurd.Hooks module),
and Postgrex :query_options.
Startup fails before supervision or claims if options, the catalog, or
Absurd.SQL.verify_schema_version/2 are invalid.