quasar_jobs
Quasar configuration and application facade.
Types
pub type ConfigError =
error.ConfigError
pub type Event =
event.Event
pub type ExecuteError =
error.ExecuteError
pub type JobOperationError =
error.JobError
pub type RequestId =
request_id.RequestId
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 enqueue_many(
new_jobs: List(job.NewJob),
runtime: Runtime,
on queue: String,
) -> Result(List(job.JobId), error.JobError)
Atomically inserts several immediately available jobs into one queue.
Stores with native batching persist the list in one operation. Use the
individual enqueue when delaying isolated requests is undesirable.
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 queue(
config: Config,
name name: String,
worker durable_worker: worker.Worker(input),
concurrency concurrency: Int,
) -> Config
Adds a named durable queue backed by a typed worker definition.
pub fn queue_with_prefetch(
config: Config,
name name: String,
worker durable_worker: worker.Worker(input),
concurrency concurrency: Int,
prefetch prefetch: Int,
) -> Config
Adds a durable queue with an explicit amount of prefetched work.
Prefer queue, whose prefetch of one avoids leasing work before a worker is
ready. Values above one trade additional leased work for throughput.
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 wake(
runtime: Runtime,
on queue: String,
) -> Result(Nil, error.JobError)
Wakes one durable queue in this runtime without changing durable state.
This is intended for store adapters that receive an external availability signal. The store remains the source of truth and the queue still polls.
pub fn with_poll_interval(
config: Config,
milliseconds: Int,
) -> Config
Sets the durable queue polling interval used as a recovery fallback.
PostgreSQL adapters can wake queues immediately through LISTEN/NOTIFY, while this interval guarantees eventual progress if a notification is lost.
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.