quasar_jobs/worker

Typed durable worker definitions.

Types

pub type CompletionMode {
  RuntimeManaged
  WorkerManaged
}

Constructors

  • RuntimeManaged
  • WorkerManaged
pub type Context {
  Context(
    job_id: job.JobId,
    attempt: Int,
    execution_token: job.ExecutionToken,
  )
}

Constructors

pub opaque type Definition
pub opaque type Worker(input)

Values

pub fn job(worker: Worker(input), input: input) -> job.NewJob

Encodes typed input into a persistable job payload.

pub fn name(worker: Worker(input)) -> String
pub fn new(
  name name: String,
  encode encode: fn(input) -> String,
  decode decode: fn(String) -> Result(input, String),
  perform perform: fn(input, Context) -> Result(Nil, String),
) -> Worker(input)

Defines a typed durable worker without macros.

pub fn with_managed_completion(
  worker: Worker(input),
) -> Worker(input)

Marks a worker as responsible for atomically persisting its own completion.

Store adapters use this for transactional workers. The callback must not return Ok until its business effect and fenced completion are committed.

Search Document