Class EddyqApp
Index
Constructors
Accessors
Methods
Accessors
hasPostgres
- get hasPostgres(): boolean
Returns boolean
hasRedis
- get hasRedis(): boolean
Whether this app has a Redis backend configured.
Returns boolean
Methods
addIntervalSchedule
- addIntervalSchedule(
provider: string,
name: string,
intervalMs: number,
kind: string,
payload: any,
priority?: number | null,
maxAttempts?: number | null,
queue?: string | null,
): Promise<void>Interval-style schedule. Supported on both Postgres and Redis since the schedule_intervals migration landed.
Parameters
- provider: string
- name: string
- intervalMs: number
- kind: string
- payload: any
Optionalpriority: number | nullOptionalmaxAttempts: number | nullOptionalqueue: string | null
Returns Promise<void>
addSchedule
- addSchedule(
provider: string,
name: string,
cron: string,
kind: string,
payload: any,
priority?: number | null,
maxAttempts?: number | null,
queue?: string | null,
): Promise<void>Parameters
- provider: string
- name: string
- cron: string
- kind: string
- payload: any
Optionalpriority: number | nullOptionalmaxAttempts: number | nullOptionalqueue: string | null
Returns Promise<void>
cancel
Cancel a pending job. The caller must specify which provider owns the id — job ids are not globally unique across backends.
Parameters
- id: number
- provider: string
Returns Promise<boolean>
clean
- clean(
graceMs: number,
limit: number,
state: "completed" | "failed" | "cancelled",
provider: string,
): Promise<number>Ad-hoc retention sweep. The caller specifies which provider to clean — retention is a backend-local notion.
Parameters
- graceMs: number
- limit: number
- state: "completed" | "failed" | "cancelled"
- provider: string
Returns Promise<number>
clearGroupRate
Parameters
- provider: string
- groupKey: string
Returns Promise<void>
close
Close the Postgres pool (no-op when no PG backend).
Returns Promise<void>
enqueue
Enqueue a job. The target backend is picked from
options.queuevia the route table — falling back todefaultProviderwhen the queue isn't in the table.Parameters
- kind: string
- payload: any
Optionaloptions: EnqueueOptions | null
Returns Promise<EnqueueOutcome>
enqueueMany
Bulk-enqueue with per-item routing. Items are grouped by their resolved provider (per
options.queue→ routes →defaultProvider), then dispatched to each backend in a singleenqueueManycall. The returned counts are the sum across both backends.Mixed batches across backends are supported in one call — useful for fan-in jobs where some children land on Redis (e.g. webhook delivery) and some on Postgres (e.g. ledger write).
Parameters
- items: EnqueueManyItem[]
Returns Promise<BulkEnqueueOutcome>
getStatsFor
Per-backend job-state snapshot. Same shape as the standalone
Eddyq.getStats/EddyqRedis.getStats— just scoped to one backend so the dashboard can render each half independently.Parameters
- provider: string
Returns Promise<JobStats>
listGroups
Parameters
- provider: string
Returns Promise<Group[]>
listJobs
Paginated job listing. Routes by
filter.queueif set, otherwise uses the default provider. Pagination doesn't compose across two backends — callers wanting cross-backend results should issue two separate calls and stitch UI-side.Parameters
Optionalfilter: ListJobsFilter | nullOptionalpagination: Pagination | null
Returns Promise<JobList>
listJobsFor
- listJobsFor(
provider: string,
filter?: ListJobsFilter | null,
pagination?: Pagination | null,
): Promise<JobList>Per-backend
listJobs. Same shape as the routedlistJobs— just scoped to one backend so a dashboard can fetch each half and stitch results UI-side (sort bycreatedAt, sum the totals).Parameters
- provider: string
Optionalfilter: ListJobsFilter | nullOptionalpagination: Pagination | null
Returns Promise<JobList>
listNamedQueues
Per-backend named-queue listing. Dashboards typically render one list per backend (since queue names aren't globally unique across backends — they can collide deliberately or accidentally).
Parameters
- provider: string
Returns Promise<NamedQueue[]>
listSchedules
Parameters
- provider: string
Returns Promise<Schedule[]>
migrate
Apply pending Postgres migrations (no-op when no PG backend). Mirrors
Eddyq.migrateso the Nest module can call it uniformly.Returns Promise<MigrateReport | null>
migrationStatus
Migration status for the Postgres backend (no-op when no PG backend).
Returns Promise<MigrationStatus[]>
pauseGroup
Parameters
- provider: string
- groupKey: string
Returns Promise<void>
pauseQueue
Parameters
- provider: string
- queue: string
Returns Promise<void>
providerFor
Which backend a queue routes to. Returns
"postgres"or"redis"based on the routing table +defaultProvider. Useful when callers need to pick provider-specific paths (e.g. NestJS@InjectQueuehandles dispatching admin calls correctly).Parameters
- queueName: string
Returns string
removeSchedule
Parameters
- provider: string
- name: string
Returns Promise<boolean>
resumeGroup
Parameters
- provider: string
- groupKey: string
Returns Promise<void>
resumeQueue
Parameters
- provider: string
- queue: string
Returns Promise<void>
setAbortHandler
Register the abort-broadcast handler. lib.cjs uses this to fan out shutdown to in-flight
AbortControllers. Stored on theEddyqAppitself — fired once at the start ofshutdown(), before either inner backend drains, so handlers see the signal regardless of which backend they're running on.Parameters
- handler: (reason: string) => void
Returns void
setGroupConcurrency
Parameters
- provider: string
- groupKey: string
- max: number
Returns Promise<void>
setGroupRate
Parameters
- provider: string
- groupKey: string
- count: number
- periodMs: number
Returns Promise<void>
setQueueConcurrency
Parameters
- provider: string
- queue: string
- max: number
Returns Promise<void>
setWorkerConcurrency
Set worker concurrency on both backends.
Parameters
- n: number
Returns void
shutdown
Drain both runtimes. Mode and timeout apply to both in sequence.
Parameters
Optionaloptions: ShutdownOptions | null
Returns Promise<void>
start
Start both backends' worker runtimes. Tuning options apply to both.
Parameters
Optionaloptions: StartOptions | null
Returns Promise<void>
subscribeTo
Subscribe each backend's worker pool to the queues that route to it. The first time this is called the routes from
connect()take effect; subsequent calls let runtime callers (e.g. NestJS dynamic queue registration) extend the subscribed set.Parameters
- queues: string[]
Returns void
syncSchedules
Reconcile the schedule list against one provider's backend. The declared entries are upserted, anything not in the list is deleted. Idempotent — safe to run on every boot. Useful when schedules are declared in module config and the caller wants to keep them in sync.
Parameters
- provider: string
- declared: ScheduleDeclaration[]
Returns Promise<SyncSchedulesReport>
work
Register a handler for
kind. The same handler is registered on every configured backend — only the backend that actually fetches a job of this kind (per itssubscribeTo) will invoke it.Parameters
- kind: string
- handler: (call: JobCall) => Promise<unknown>
Returns void
Staticconnect
Construct + connect both backends.
queuesdeclares the routing table (queue name → "postgres" | "redis"). Unrouted queue names fall back todefaultProvider; if that's omitted, the only configured backend wins.Parameters
- config: EddyqAppConfig
Returns Promise<EddyqApp>
Whether this app has a Postgres backend configured. Lets callers decide whether to call PG-only methods (
migrate,enqueueBatch).