pub fn queue(ctx: &Ctx, name: &'static str) -> QueueExpand description
A named queue, for jobs that must not wait behind others: ocre::jobs::queue(&ctx, "urgent").enqueue(&job).
Cloudflare Queues has no priorities: Ocre gives urgent work its own
queue instead, like Rails’ queue_as/set(queue:) and Loco’s named
queues. Each queue has its own consumer settings in cloudflare.config.ts
(ocre g job <Name> --queue urgent adds <app>-jobs-urgent with
maxBatchTimeout: 1), so a backlog of slow jobs on default never
delays it. Every queue is consumed by the same queue event and the
same perform. The name default is the JOBS queue of
enqueue; urgent is bound as JOBS_URGENT.
Free-plan cost: queues are free to create; each message costs the same 3 operations whatever its queue.
§Examples
use ocre::{Ctx, Result};
use serde::Serialize;
#[derive(Serialize)]
#[serde(rename_all = "snake_case")]
enum Job {
SendMagicLink { user_id: i64 },
}
async fn sign_in(ctx: &Ctx) -> Result<()> {
ocre::jobs::queue(ctx, "urgent").enqueue(&Job::SendMagicLink { user_id: 1 }).await
}