FerricStore.Flow.Worker (ferricstore v0.4.2)

Copy Markdown View Source

Optional polling worker for FerricStore.Flow.Workflow modules.

The worker is a convenience loop around workflow.claim_due/2. It does not add a scheduler or queue truth layer. Flow remains the durable source of leases, retries, fencing tokens, and state transitions.

Example

children = [
  {FerricStore.Flow.Worker,
   workflow: BillingFlow,
   state: :created,
   worker: "payment-#{node()}",
   limit: 100,
   interval_ms: 250,
   handler: &MyApp.PaymentWorker.handle/1}
]

Handler return values:

  • {:ok, result} - calls workflow.ok(job, result)
  • {:error, reason} - calls workflow.error(job, reason)
  • :noreply - leaves the job leased; handler owns the final Flow command

Exceptions are caught and passed to workflow.error/2. This keeps worker crashes from losing the lease path; expired leases can still be reclaimed by later claim_due or reclaim calls.

Summary

Functions

Returns a specification to start this module under a supervisor.

Types

option()

@type option() ::
  {:workflow, module()}
  | {:state, atom() | binary() | [atom() | binary()]}
  | {:worker, binary()}
  | {:handler, (FerricStore.Flow.Job.t() -> term())}
  | {:limit, pos_integer()}
  | {:interval_ms, non_neg_integer()}
  | {:claim_opts, keyword()}
  | GenServer.option()

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts)

@spec start_link([option()]) :: GenServer.on_start()