quasar_jobs

Quasar configuration and application facade.

Types

pub opaque type Config
pub type Event =
  event.Event
pub type JobOperationError =
  error.JobError
pub opaque type Runtime
pub type StartError =
  error.StartError

Values

pub fn call(
  runtime: Runtime,
  on pool: String,
  timeout timeout: Int,
  run run: fn() -> output,
) -> Result(output, error.ExecuteError)

Executes a typed ephemeral call on a named pool.

A deadline error means the handler may still complete. Quasar never retries local calls automatically.

pub fn call_with_id(
  runtime: Runtime,
  on pool: String,
  id id: request_id.RequestId,
  timeout timeout: Int,
  run run: fn() -> output,
) -> Result(output, error.ExecuteError)

Executes a call with an existing correlation identity (for HTTP adapters).

pub fn cancel_job(
  runtime: Runtime,
  id: job.JobId,
) -> Result(job.Job, error.JobError)

Cancels a non-terminal durable job.

pub fn cast(
  runtime: Runtime,
  on pool: String,
  run run: fn() -> Nil,
) -> Result(Nil, error.ExecuteError)

Submits ephemeral fire-and-forget work with at-most-once semantics.

pub fn enqueue(
  new_job: job.NewJob,
  runtime: Runtime,
  on queue: String,
) -> Result(job.JobId, error.JobError)

Inserts a durable job for immediate execution.

pub fn get_job(
  runtime: Runtime,
  id: job.JobId,
) -> Result(job.Job, error.JobError)

Fetches the latest durable state for a job.

pub fn local_pool(
  config: Config,
  name name: String,
  workers workers: Int,
  prefetch prefetch: Int,
  buffer_capacity buffer_capacity: Int,
) -> Config

Adds a named ephemeral local pool.

prefetch defaults conceptually to 1 for synchronous calls; callers that choose a larger value allow one worker to reserve multiple tasks at once.

pub fn new() -> Config

Creates an empty Quasar runtime configuration.

pub fn queue(
  config: Config,
  name name: String,
  worker durable_worker: worker.Worker(input),
  concurrency concurrency: Int,
  prefetch prefetch: Int,
) -> Config

Adds a named durable queue backed by a typed worker definition.

pub fn request_id_to_string(id: request_id.RequestId) -> String

Returns the printable representation of a request identity.

pub fn retry_job(
  runtime: Runtime,
  id: job.JobId,
) -> Result(job.Job, error.JobError)

Makes a discarded, cancelled, or retryable job immediately available.

pub fn schedule(
  new_job: job.NewJob,
  runtime: Runtime,
  on queue: String,
  at available_at: Int,
) -> Result(job.JobId, error.JobError)

Inserts a durable job that becomes available at an epoch millisecond.

pub fn start(config: Config) -> Result(Runtime, error.StartError)

Starts the configured runtime and all local pools.

pub fn stop(runtime: Runtime) -> Result(Nil, error.ExecuteError)

Stops accepting work and drains pools. Ok confirms draining succeeded; an error may return before draining finishes. Never closes the Store.

pub fn supervised(
  config: Config,
) -> Result(
  supervision.ChildSpecification(Runtime),
  error.ConfigError,
)

Creates an OTP child specification for a Quasar runtime.

The runtime owns linked local pools, durable schedulers, source-backed pools, and its asynchronous reporter. A fatal child exit therefore takes down the runtime owner so the application supervisor can restart the unit.

pub fn with_reporter(
  config: Config,
  reporter: fn(event.Event) -> Nil,
) -> Config

Installs the runtime event reporter.

Events are delivered from a dedicated process, so a slow reporter never blocks Constellation’s Stage or worker-pool processes.

pub fn with_shutdown_timeout(
  config: Config,
  milliseconds: Int,
) -> Config

Sets the maximum time synchronous shutdown operations may take.

pub fn with_store(
  config: Config,
  durable_store: store.Store,
) -> Config

Enables durable jobs using a Store implementation.

Search Document