Types
All types are exported from the package root.
JobHandler
Section titled “JobHandler”The function a job runs. Sync or async. Returning means success; throwing means failure, or interrupted when ctx.signal was aborted by stop() or a takeover first.
JobContext
Section titled “JobContext”Guide: Writing handlers.
JobData, JobDataProvider
Section titled “JobData, JobDataProvider”What the data option of a scheduler, a job and runNow() takes: a value, or a function called when a run starts. Guide: Run data.
RunReason
Section titled “RunReason”| Value | Meaning |
|---|---|
'scheduled' |
The run was due |
'manual' |
runNow() was called |
'catch-up' |
It was due while every instance was down |
'takeover' |
A backup started the next attempt of a run whose runner was gone |
JobOptions, EveryJobOptions, CronJobOptions, AtJobOptions
Section titled “JobOptions, EveryJobOptions, CronJobOptions, AtJobOptions”See Options.
Decorator types
Section titled “Decorator types”| Type | What it is |
|---|---|
DecoratedJobOptions |
What @Every, @Cron and @At accept when the name isn’t the first argument |
JobPlacement |
{ scheduler? }, the part of it that the form with the name first also accepts |
JobDecorator, ScheduledDecorator |
What the method decorators and @Scheduled() return: decorators in both the standard and the legacy style |
RegisterOptions |
The options of scheduler.register() |
ConfigureOptions |
The settings Scheduler.configure() takes |
See Decorators.
JobInfo
Section titled “JobInfo”What jobs() returns for each job.
RunKey, RunEvent, RunRecord
Section titled “RunKey, RunEvent, RunRecord”RunKey names one run: a job and its scheduled time. RunEvent adds when it was due and which instance it is about; RunRecord and the run events (RunStartEvent, SkipEvent, LostEvent) extend it, so one function can read any of them. A RunRecord is one attempt of one run. Returned by history(), lastRun() and runNow(), and the payload of success.
RunStatus
Section titled “RunStatus”Guide: History.
Scheduler
Section titled “Scheduler”SchedulerOptions, LeaseSchedulerOptions
Section titled “SchedulerOptions, LeaseSchedulerOptions”Scheduler takes its backend’s type, Scheduler<B>, so its options and those of every(), cron() and at() depend on the backend. A backend “has leases” when its runs may be set: PostgreSQL, SQLite, Redis or Valkey with the lease strategy, and any value typed only as Backend. On the others, LeaseSchedulerOptions and LeaseJobOptions aren’t offered. See Options.
Logger
Section titled “Logger”console, pino and winston loggers all fit.
KeyValueStrategies, KeyValueStrategyName, KeyValueStrategy
Section titled “KeyValueStrategies, KeyValueStrategyName, KeyValueStrategy”The strategies of the key-value backends, by server. KeyValueStrategy is the strategy option of RedisBackend; ValkeyBackend takes KeyValueStrategy<KeyValueStrategyName<'valkey'>>, with no idmp because Valkey can’t run it. A strategy’s settings go inside it, so they can’t be given to another strategy. lease (the default) also gives no overlapping runs, backup runners, catch-up and retries. stream-id, script and idmp (Redis 8.6+) only decide who runs each time. Redis and Valkey explains each one. PostgreSQL and SQLite have no strategy option: they always follow the lease rules. RabbitMQ always makes a simple claim. NatsBackend takes NatsStrategyName: 'msg-id' (the default) makes a simple claim, 'lease' follows the lease rules; see NATS.
IdmpOptions, ScriptOptions
Section titled “IdmpOptions, ScriptOptions”The settings of { name: 'idmp' } and { name: 'script' }.
Events
Section titled “Events”SchedulerEvents, RunStartEvent, RunFailureEvent, RunInterruptedEvent, SkipEvent, LostEvent and SchedulerErrorEvent are described in Events.
Backends
Section titled “Backends”These matter when you write a backend.
Backend
Section titled “Backend”ClaimInput
Section titled “ClaimInput”StoredResult
Section titled “StoredResult”What the runner stores when an attempt ends.
JobLimits
Section titled “JobLimits”What checkJob() receives, so a backend can refuse a job it can’t run safely.
RunStore
Section titled “RunStore”The optional lease capability of a backend.
RunClaim
Section titled “RunClaim”ClaimOutcome
Section titled “ClaimOutcome”Each outcome is explained in Run lifecycle.
Client shapes
Section titled “Client shapes”The minimal shape anarchon needs from each client library. You pass a real client; these types exist so anarchon doesn’t depend on the libraries themselves.
| Type | Matches |
|---|---|
KeyValueConnection |
Anything accepted as redis (RedisBackend) or valkey (ValkeyBackend) |
KeyValueClient |
{ send(command, args) } |
KeyValueConnectionOptions |
{ host, port, username, password, db } |
IORedisLike, NodeRedisLike, ValkeyGlideLike |
ioredis / iovalkey, node-redis, Valkey GLIDE |
PgPoolLike, PgClientLike, PostgresJsLike |
pg Pool, pg Client, postgres.js |
SqliteDatabaseLike, LibsqlClientLike |
node:sqlite / better-sqlite3, @libsql/client |
SqlClient, SqlQuery, SqlRow, SqlValue |
The { all, transaction } adapter of the SQL backends |
SqlDialect |
What a subclass of SqlBackend gives for another SQL database |
RabbitMQConnectionLike, NatsConnectionLike |
An amqplib connection, a NATS connection |
Backend option types: RedisBackendOptions, ValkeyBackendOptions, PostgresBackendOptions, SqliteBackendOptions, RabbitMQBackendOptions, NatsBackendOptions. See Options.