Skip to content

Class: KyooQueue<T>

An instance of a queue created by Kyoo with the queue broker. A queue is created by calling the get method of KyooConnection.queues

Type Parameters

Type ParameterDescription
T extends KyooClientThe type of the Queue Broker client. Will be one of: amqp, bullmq and sqs.

Accessors

jobs

Get Signature

ts
get jobs(): {
  enqueue: <T>(job: KyooJobToEnqueue<T>, ...jobs: KyooJobToEnqueue<T>[]) => Promise<boolean | boolean[]>;
  enqueued: () => Promise<number>;
  fetch: <T>(count?: number) => Promise<KyooJob<T>[]>;
  next: <T>(noAck: boolean) => Promise<undefined | KyooWorkable<T>>;
  purge: () => Promise<void>;
};

An object of methods for interacting with jobs

Returns
ts
{
  enqueue: <T>(job: KyooJobToEnqueue<T>, ...jobs: KyooJobToEnqueue<T>[]) =>
    Promise<boolean | boolean[]>;
  enqueued: () => Promise<number>;
  fetch: <T>(count?: number) => Promise<KyooJob<T>[]>;
  next: <T>(noAck: boolean) => Promise<undefined | KyooWorkable<T>>;
  purge: () => Promise<void>;
}
NameTypeDescription
enqueue()<T>(job: KyooJobToEnqueue<T>, ...jobs: KyooJobToEnqueue<T>[]) => Promise<boolean | boolean[]>Add one or more jobs to the queue
enqueued()() => Promise<number>Get the number of jobs in the queue
fetch()<T>(count?: number) => Promise<KyooJob<T>[]>Get a list of pending jobs in the queue Remarks Depending on the adapter this operation may be expensive.
next()<T>(noAck: boolean) => Promise<undefined | KyooWorkable<T>>Retrieve the next job from the queue, if one is available
purge()() => Promise<void>Removes all unprocessed jobs from the queue

name

Get Signature

ts
get name(): string;

The name of the queue

Returns

string


version

Get Signature

ts
get version(): string;

The version of the library

Returns

string

The version of the library


workers

Get Signature

ts
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


version

Get Signature

ts
get static version(): string;

The version of the library

Returns

string

The version of the library

Methods

terminate()

ts
terminate(): Promise<void>;

Terminate all queue subscriptions by resolving any pending promises for subscriptions

Returns

Promise<void>


worker()

ts
worker<M>(processor: KyooJobProcessor<M>, options?: Partial<KyooQueueWorkerOptions>): KyooWorker<T, M>;

Create a worker for the queue

Type Parameters

Type ParameterDefault type
MKyooSerializable

Parameters

ParameterTypeDescription
processorKyooJobProcessor<M>The function to process the job
options?Partial<KyooQueueWorkerOptions>Options for the worker

Returns

KyooWorker<T, M>

An instance of the KyooQueueWorker matching the desired options

Throws

KyooUnacceptableWorkerOptionsError if the options are invalid