Skip to content

JobsRuntime

  • OnApplicationBootstrap
  • OnModuleDestroy
  • OnApplicationShutdown

new JobsRuntime(options, discovery, scanner, reflector, moduleRef): JobsRuntime

JobsModuleOptions

DiscoveryService

MetadataScanner

Reflector

ModuleRef

JobsRuntime

get producerConnection(): Redis

The shared producer client. Exposed for health checks; never send blocking commands on it.

Redis


get scheduledSweeps(): readonly string[]

The sweeps scheduled at boot, by name.

readonly string[]

close(): Promise<void>

Drains, then closes every queue and the producer connection, in that order. Idempotent.

Promise<void>


drain(timeoutMs?): Promise<DrainResult>

Stops every worker from taking new jobs and waits up to timeoutMs for the running ones. A worker still busy after that is closed anyway: its jobs’ locks lapse and another worker picks them up as stalled. Idempotent.

number

Promise<DrainResult>


onApplicationBootstrap(): Promise<void>

Promise<void>

OnApplicationBootstrap.onApplicationBootstrap


onApplicationShutdown(): Promise<void>

Promise<void>

OnApplicationShutdown.onApplicationShutdown


onModuleDestroy(): Promise<void>

Nest’s own shutdown hooks, for apps that do not use the shutdown helper.

Promise<void>

OnModuleDestroy.onModuleDestroy


queue<Jobs>(definition): JobQueue<Jobs>

The JobQueue of definition, created on first use. One policy per queue name.

Jobs extends object

QueueDefinition<Jobs>

JobQueue<Jobs>


whenSweepsScheduled(): Promise<void>

Resolves once the sweep schedulers are in Redis and stale ones are removed.

Promise<void>