Class: KyooQueue<T>
Provides queue operations and worker creation through a configured broker adapter.
Remarks
Obtain handles with KyooConnection.queues. A handle can be created before its connection is established; individual operations follow the adapter's connection policy.
Type Parameters
| Type Parameter | Description |
|---|---|
T extends KyooClient | Broker client: amqp, bullmq, sqs, pgboss, or sql. |
Accessors
jobs
Get Signature
get jobs(): {
enqueue: <JT>(job: KyooJobToEnqueue<JT>, ...jobs: KyooJobToEnqueue<JT>[]) => Promise<boolean | boolean[]>;
enqueued: () => Promise<number>;
fetch: <JT>(count?: number) => Promise<KyooJob<JT>[]>;
next: <JT>(noAck: boolean) => Promise<undefined | KyooWorkable<JT>>;
purge: () => Promise<void>;
};An object of methods for interacting with jobs
Returns
Operations for enqueueing, counting, purging, retrieving, and inspecting jobs on this queue.
| Name | Type | Description |
|---|---|---|
enqueue() | <JT>(job: KyooJobToEnqueue<JT>, ...jobs: KyooJobToEnqueue<JT>[]) => Promise<boolean | boolean[]> | Enqueues one or more jobs through the configured broker adapter. Throws when the required first job is missing. |
enqueued() | () => Promise<number> | Counts jobs according to the configured adapter's queue semantics. Remarks AMQP, BullMQ, and pg-boss throw KyooNotConnectedError when disconnected regardless of rejectEnqueueIfNotConnected; SQS honours the option (returning NaN when the option is off); SQL performs no connection check. |
fetch() | <JT>(count?: number) => Promise<KyooJob<JT>[]> | Inspects pending jobs using the configured broker adapter. Throws when count fails non-negative integer validation. Remarks AMQP, SQS, and pg-boss retrieval can change broker state by consuming and requeueing or resetting visibility; pg-boss also updates attempts. BullMQ and SQL inspection is read-only. Fetching all jobs may be expensive. |
next() | <JT>(noAck: boolean) => Promise<undefined | KyooWorkable<JT>> | Retrieves the next available job for processing. Throws when disconnected and the adapter's rejection option is enabled. |
purge() | () => Promise<void> | Removes all unprocessed jobs from the queue through the configured adapter. |
name
Get Signature
get name(): string;Reads the broker queue name represented by this handle.
Returns
string
The queue name supplied when this handle was created.
version
Get Signature
get version(): string;The version of the library
Returns
string
The version of the library
workers
Get Signature
get workers(): number;The number of workers attached to this queue instance
Remarks
This number only counts the workers created by this instance of the queue, not the workers created by other instances of the queue or workers created in other processes.
Returns
number
Number of worker buses currently stored by this handle, keyed by worker name.
version
Get Signature
get static version(): string;The version of the library
Returns
string
The version of the library
Methods
terminate()
terminate(): Promise<void>;Terminates all workers created from this queue and removes their lifecycle buses.
Returns
Promise<void>
A promise fulfilled after every worker has received its termination signal.
worker()
worker<M>(processor: KyooJobProcessor<M>, options?: Partial<KyooQueueWorkerOptions>): KyooWorker<T, M>;Creates a KyooWorker registered under its validated name.
Type Parameters
| Type Parameter | Default type |
|---|---|
M | KyooSerializable |
Parameters
| Parameter | Type | Description |
|---|---|---|
processor | KyooJobProcessor<M> | Callback receiving each job and its disposition and worker controls. |
options? | Partial<KyooQueueWorkerOptions> | Optional settings validated with independent defaults. |
Returns
KyooWorker<T, M>
A worker bound to this queue and configured with validated options.
Throws
when the options fail validation.
