Skip to content

basalt / scheduler/src / Scheduler

Class: Scheduler ​

Defined in: scheduler/src/index.ts:294

Constructors ​

Constructor ​

> new Scheduler(options?): Scheduler

Defined in: scheduler/src/index.ts:305

Parameters ​

options? ​

SchedulerOptions = {}

Returns ​

Scheduler

Properties ​

hooks ​

> readonly hooks: HookBus | undefined

Defined in: scheduler/src/index.ts:301

The hook bus reconcilers emit on (the app's, under schedulerPlugin).


skippedByLock ​

> skippedByLock: number = 0

Defined in: scheduler/src/index.ts:303

ticks skipped because another replica held the lock — for observability/tests

Methods ​

call() ​

> call(name, task): ScheduleEntry

Defined in: scheduler/src/index.ts:327

Schedules a named function.

Parameters ​

name ​

string

task ​

Task

Returns ​

ScheduleEntry


job() ​

> job<T>(job, ...payload): ScheduleEntry

Defined in: scheduler/src/index.ts:322

Schedules the dispatch of a @basaltkit/queue job.

Type Parameters ​

T ​

T

Parameters ​

job ​

JobDefinition<T>

payload ​

...T extends void ? [] : [T]

Returns ​

ScheduleEntry


list() ​

> list(): object[]

Defined in: scheduler/src/index.ts:331

Returns ​

object[]


names() ​

> names(): string[]

Defined in: scheduler/src/index.ts:336

Names of every scheduled entry — for CLI validation/listing.

Returns ​

string[]


runNow() ​

> runNow(name): Promise<boolean>

Defined in: scheduler/src/index.ts:345

Runs a single entry by name on demand, ignoring its cron (for schedule:run and manual triggers). Returns false if no entry has that name. The entry's own overlap guard and failure handler still apply.

Parameters ​

name ​

string

Returns ​

Promise<boolean>


start() ​

> start(): void

Defined in: scheduler/src/index.ts:388

Aligns to the next minute and then runs tick() every 60s.

Returns ​

void


stop() ​

> stop(): void

Defined in: scheduler/src/index.ts:399

Returns ​

void


tick() ​

> tick(date?): Promise<void>

Defined in: scheduler/src/index.ts:357

Runs the entries due at the given instant. Deterministic — this is what the tests call directly and what the timer calls every minute. Failures (without onFailure) are aggregated; all due entries run.

Parameters ​

date? ​

Date = ...

Returns ​

Promise<void>

Released under the MIT License.