CloudflareObjectJobQueue
Defined in: packages/messaging/src/adapters/cloudflare/object-job-queue.ts:76
Type Parameters
Section titled “Type Parameters”T
Implements
Section titled “Implements”JobQueue<T>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new CloudflareObjectJobQueue<
T>(storage,options?):CloudflareObjectJobQueue<T>
Defined in: packages/messaging/src/adapters/cloudflare/object-job-queue.ts:82
options may also be the key prefix.
Parameters
Section titled “Parameters”storage
Section titled “storage”options?
Section titled “options?”string | CloudflareObjectJobQueueOptions<T>
Returns
Section titled “Returns”CloudflareObjectJobQueue<T>
Methods
Section titled “Methods”cleanupTerminal()
Section titled “cleanupTerminal()”cleanupTerminal(
options?):Promise<number>
Defined in: packages/messaging/src/adapters/cloudflare/object-job-queue.ts:346
Removes finished jobs: completed and failed ones by default, or those
with the given statuses, and with olderThan, only those that finished
before it.
Parameters
Section titled “Parameters”options?
Section titled “options?”JobQueueCleanupOptions | JobStatus[]
Returns
Section titled “Returns”Promise<number>
Implementation of
Section titled “Implementation of”clear()
Section titled “clear()”clear():
Promise<void>
Defined in: packages/messaging/src/adapters/cloudflare/object-job-queue.ts:334
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”complete()
Section titled “complete()”complete(
jobId,result?):Promise<void>
Defined in: packages/messaging/src/adapters/cloudflare/object-job-queue.ts:210
Marks the job completed and keeps result with it when it can be
stored as JSON. A result that cannot be stored is logged and dropped,
never failing the completion, since callers such as JobProcessor
would treat that as a failed job and run it again.
Parameters
Section titled “Parameters”string
result?
Section titled “result?”unknown
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”dequeue()
Section titled “dequeue()”dequeue(
options?):Promise<CloudflareObjectJob<T> |undefined>
Defined in: packages/messaging/src/adapters/cloudflare/object-job-queue.ts:127
Takes the next due job and, with leaseMs, leases it. Jobs whose lease
expired are due again first, or fail when they have no attempts left.
Jobs in options.running are left as they are.
Parameters
Section titled “Parameters”options?
Section titled “options?”JobDequeueOptions = {}
Returns
Section titled “Returns”Promise<CloudflareObjectJob<T> | undefined>
Implementation of
Section titled “Implementation of”enqueue()
Section titled “enqueue()”enqueue(
type,data,options?):Promise<CloudflareObjectJob<T>>
Defined in: packages/messaging/src/adapters/cloudflare/object-job-queue.ts:93
Parameters
Section titled “Parameters”string
T
options?
Section titled “options?”delay?
Section titled “delay?”number
maxAttempts?
Section titled “maxAttempts?”number
metadata?
Section titled “metadata?”Record<string, any>
priority?
Section titled “priority?”number
Returns
Section titled “Returns”Promise<CloudflareObjectJob<T>>
Implementation of
Section titled “Implementation of”fail()
Section titled “fail()”fail(
jobId,error,retry?):Promise<void>
Defined in: packages/messaging/src/adapters/cloudflare/object-job-queue.ts:237
A completed job stays completed, even for a worker whose lease expired.
Parameters
Section titled “Parameters”string
string | Error
retry?
Section titled “retry?”JobRetryDirective = ...
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”getJob()
Section titled “getJob()”getJob(
jobId):Promise<CloudflareObjectJob<T> |undefined>
Defined in: packages/messaging/src/adapters/cloudflare/object-job-queue.ts:321
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<CloudflareObjectJob<T> | undefined>
Implementation of
Section titled “Implementation of”nextDueAt()
Section titled “nextDueAt()”nextDueAt():
Promise<Date|undefined>
Defined in: packages/messaging/src/adapters/cloudflare/object-job-queue.ts:305
When dequeue() next has work: the earliest due time of a pending job
or lease expiry of a processing one, and now for a processing job that
has no lease yet. A time in the past means dequeue() has work now,
even when it only settles an expired lease, so call dequeue() rather
than checking size(). undefined when no job is pending or leased.
Use it to set a Durable Object alarm instead of polling.
Returns
Section titled “Returns”Promise<Date | undefined>
Implementation of
Section titled “Implementation of”peek()
Section titled “peek()”peek():
Promise<CloudflareObjectJob<T> |undefined>
Defined in: packages/messaging/src/adapters/cloudflare/object-job-queue.ts:275
The job dequeue() would take next, including one whose lease expired,
shown as it will be once it is due again. Changes nothing.
Returns
Section titled “Returns”Promise<CloudflareObjectJob<T> | undefined>
Implementation of
Section titled “Implementation of”remove()
Section titled “remove()”remove(
jobId):Promise<boolean>
Defined in: packages/messaging/src/adapters/cloudflare/object-job-queue.ts:327
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<boolean>
Implementation of
Section titled “Implementation of”size()
Section titled “size()”size():
Promise<number>
Defined in: packages/messaging/src/adapters/cloudflare/object-job-queue.ts:287
How many jobs are due now, including those whose lease expired.
Returns
Section titled “Returns”Promise<number>