Skip to main content

Class: ScheduledTaskHandler

Constructors

new ScheduledTaskHandler()

new ScheduledTaskHandler(options: ScheduledTaskHandlerOptions): ScheduledTaskHandler

Parameters

ParameterType
optionsScheduledTaskHandlerOptions

Returns

ScheduledTaskHandler

Defined in

lib/ScheduledTaskHandler.ts:37

Properties

#client

private #client: BullClient

Defined in

lib/ScheduledTaskHandler.ts:34


#worker

private #worker: Worker<any, any, string>

Defined in

lib/ScheduledTaskHandler.ts:35


options

readonly options: QueueOptions

The queue options for the scheduled task handler.

Defined in

lib/ScheduledTaskHandler.ts:27


queue

readonly queue: string

The name of the queue associated with the scheduled task handler.

Defined in

lib/ScheduledTaskHandler.ts:32

Accessors

client

Get Signature

get client(): BullClient

Returns

BullClient

Defined in

lib/ScheduledTaskHandler.ts:64


store

Get Signature

get private store(): ScheduledTaskStore

Returns

ScheduledTaskStore

Defined in

lib/ScheduledTaskHandler.ts:233

Methods

close()

close(): Promise<void>

Closes the internal client and worker.

Returns

Promise<void>

Defined in

lib/ScheduledTaskHandler.ts:71


create()

create<T>(task: T, options?: number | ScheduledTasksTaskOptions): Promise<ScheduledTasksJob<T>>

Creates a scheduled task.

Type Parameters

Type Parameter
T extends ScheduledTasksResolvable

Parameters

ParameterTypeDescription
taskTThe task to be scheduled.
options?number | ScheduledTasksTaskOptionsThe options for the task.

Returns

Promise<ScheduledTasksJob<T>>

Defined in

lib/ScheduledTaskHandler.ts:84


createRepeated()

createRepeated(tasks?: ScheduledTaskCreateRepeatedTask[]): Promise<void>

Creates repeated tasks.

Parameters

ParameterTypeDescription
tasks?ScheduledTaskCreateRepeatedTask[]An optional array of tasks to create. If not provided, it will create tasks based on the stored repeated tasks.

Returns

Promise<void>

Defined in

lib/ScheduledTaskHandler.ts:124


delete()

delete(id: string): Promise<void>

Deletes a scheduled task by its ID.

Parameters

ParameterTypeDescription
idstringThe ID of the task to delete.

Returns

Promise<void>

Defined in

lib/ScheduledTaskHandler.ts:156


get()

get<T>(id: T): Promise<undefined | Job<undefined, any, string>>

Retrieves a scheduled task by its ID.

Type Parameters

Type Parameter
T extends never

Parameters

ParameterTypeDescription
idTThe ID of the scheduled task to retrieve.

Returns

Promise<undefined | Job<undefined, any, string>>

Defined in

lib/ScheduledTaskHandler.ts:188


list()

list(options: ScheduledTaskListOptions): Promise<Job<unknown, any, string>[]>

Retrieves a list of scheduled tasks based on the provided options.

Parameters

ParameterTypeDescription
optionsScheduledTaskListOptionsThe options for filtering the list of scheduled tasks.

Returns

Promise<Job<unknown, any, string>[]>

Defined in

lib/ScheduledTaskHandler.ts:166


listRepeated()

listRepeated(options: ScheduledTaskListRepeatedOptions): Promise<RepeatableJob[]>

Retrieves a list of repeated scheduled tasks based on the provided options.

Parameters

ParameterTypeDescription
optionsScheduledTaskListRepeatedOptionsThe options for filtering the list of repeated scheduled tasks.

Returns

Promise<RepeatableJob[]>

Defined in

lib/ScheduledTaskHandler.ts:177


resolveTask()

private resolveTask(task: ScheduledTasksResolvable): ScheduledTasksResolvablePayload<never>

Parameters

ParameterType
taskScheduledTasksResolvable

Returns

ScheduledTasksResolvablePayload<never>

Defined in

lib/ScheduledTaskHandler.ts:237


run()

run(task: ScheduledTasksResolvable): Promise<undefined | null | number>

Runs a scheduled task with the given name and payload.

Parameters

ParameterTypeDescription
taskScheduledTasksResolvableThe name of the scheduled task to run.

Returns

Promise<undefined | null | number>

Remarks

undefined will be returned if the task was not found.

Defined in

lib/ScheduledTaskHandler.ts:202