@aponiajs/queue 0.0.0-stage → 1.0.0-beta.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +275 -2
- package/dist/index.d.mts +427 -0
- package/dist/index.mjs +1001 -0
- package/llms.txt +38 -0
- package/package.json +57 -4
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
import { ConfigurableModuleAsyncOptions, DynamicModule, Inject, InjectionToken, ModuleAsyncOptions, OnModuleDestroy, OnModuleInit } from "@aponiajs/common";
|
|
2
|
+
import { Database } from "bun:sqlite";
|
|
3
|
+
/** One recorded message waiting to be delivered. */
|
|
4
|
+
interface OutboxMessage<TPayload = unknown> {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly payload: TPayload;
|
|
8
|
+
readonly attempts: number;
|
|
9
|
+
readonly recordedAt: number;
|
|
10
|
+
}
|
|
11
|
+
/** The sink `OutboxService.flush` delivers into. */
|
|
12
|
+
/** A promise-returning sink is awaited before the message is removed. */
|
|
13
|
+
type OutboxSink = (message: OutboxMessage) => unknown;
|
|
14
|
+
/** Registration options for one outbox. */
|
|
15
|
+
interface OutboxOptions {
|
|
16
|
+
/** How many messages may wait at once; defaults to 1000. */
|
|
17
|
+
readonly maxEntries?: number;
|
|
18
|
+
/** The clock a record reads; defaults to `Date.now`. */
|
|
19
|
+
readonly now?: () => number;
|
|
20
|
+
/**
|
|
21
|
+
* A synchronous durable store. The service hydrates from it at construction
|
|
22
|
+
* and writes every change back; omitting it keeps the outbox process-local.
|
|
23
|
+
*/
|
|
24
|
+
readonly store?: OutboxStore;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A durable home for recorded messages.
|
|
28
|
+
*
|
|
29
|
+
* The operations are synchronous so `record` stays synchronous: a SQLite
|
|
30
|
+
* driver is synchronous, and a network store belongs behind an application
|
|
31
|
+
* adapter rather than in this contract.
|
|
32
|
+
*/
|
|
33
|
+
interface OutboxStore {
|
|
34
|
+
/** Every stored message, oldest first. */
|
|
35
|
+
list(): readonly OutboxMessage[];
|
|
36
|
+
append(message: OutboxMessage): void;
|
|
37
|
+
update(message: OutboxMessage): void;
|
|
38
|
+
remove(id: string): void;
|
|
39
|
+
clear(): void;
|
|
40
|
+
}
|
|
41
|
+
/** Options one `flush` run accepts. */
|
|
42
|
+
interface OutboxFlushOptions {
|
|
43
|
+
/** Stops between messages; the undelivered tail stays in the outbox. */
|
|
44
|
+
readonly signal?: AbortSignal;
|
|
45
|
+
}
|
|
46
|
+
/** What one `flush` run delivered. */
|
|
47
|
+
interface OutboxFlushResult {
|
|
48
|
+
readonly delivered: number;
|
|
49
|
+
readonly remaining: number;
|
|
50
|
+
}
|
|
51
|
+
/** Where one job stands. */
|
|
52
|
+
type QueueJobState = "pending" | "running" | "completed" | "failed";
|
|
53
|
+
/** A frozen view of one job. */
|
|
54
|
+
interface QueueJob<TPayload = unknown> {
|
|
55
|
+
readonly id: string;
|
|
56
|
+
readonly name: string;
|
|
57
|
+
readonly payload: TPayload;
|
|
58
|
+
/** How many times the handler ran; `0` before the first attempt. */
|
|
59
|
+
readonly attempts: number;
|
|
60
|
+
readonly maxAttempts: number;
|
|
61
|
+
/** The dispatch priority; a higher value runs first. Defaults to `0`. */
|
|
62
|
+
readonly priority: number;
|
|
63
|
+
/** How long one attempt may run; `0` means no limit. */
|
|
64
|
+
readonly timeoutMs: number;
|
|
65
|
+
readonly state: QueueJobState;
|
|
66
|
+
readonly enqueuedAt: number;
|
|
67
|
+
/** When the next attempt may run. */
|
|
68
|
+
readonly availableAt: number;
|
|
69
|
+
readonly idempotencyKey?: string;
|
|
70
|
+
readonly lastError?: string;
|
|
71
|
+
}
|
|
72
|
+
/** A handler a queue runs for one job name. */
|
|
73
|
+
type QueueHandler<TPayload = unknown> = (payload: TPayload, job: QueueJob<TPayload>,
|
|
74
|
+
/** Aborted on timeout or shutdown; a handler that ignores it keeps running. */
|
|
75
|
+
signal?: AbortSignal) => unknown;
|
|
76
|
+
/** The per-job options `enqueue` accepts. */
|
|
77
|
+
interface QueueEnqueueOptions {
|
|
78
|
+
/** Overrides the registration's attempt budget for this job. */
|
|
79
|
+
readonly maxAttempts?: number;
|
|
80
|
+
/** Suppresses a second enqueue while a job with this key is pending or running. */
|
|
81
|
+
readonly idempotencyKey?: string;
|
|
82
|
+
/** Defers the first attempt until this time; defaults to now. */
|
|
83
|
+
readonly availableAt?: number;
|
|
84
|
+
/** The dispatch priority; a higher value runs before a lower one. */
|
|
85
|
+
readonly priority?: number;
|
|
86
|
+
/** Overrides the registration's attempt timeout for this job. */
|
|
87
|
+
readonly timeoutMs?: number;
|
|
88
|
+
}
|
|
89
|
+
/** What one `drain()` run did. */
|
|
90
|
+
interface QueueDrainSummary {
|
|
91
|
+
readonly completed: number;
|
|
92
|
+
readonly retried: number;
|
|
93
|
+
readonly deadLettered: number;
|
|
94
|
+
readonly skipped: number;
|
|
95
|
+
}
|
|
96
|
+
/** A count of the queue's current contents. */
|
|
97
|
+
interface QueueStats {
|
|
98
|
+
readonly pending: number;
|
|
99
|
+
readonly running: number;
|
|
100
|
+
readonly deadLettered: number;
|
|
101
|
+
}
|
|
102
|
+
/** The timer `QueueService` uses for background draining. */
|
|
103
|
+
interface QueueTimer {
|
|
104
|
+
setTimeout(handler: () => void, delayMs: number): unknown;
|
|
105
|
+
clearTimeout(handle: unknown): void;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The backlog a queue keeps outside its own memory.
|
|
109
|
+
*
|
|
110
|
+
* A store receives every job state the service records, so a durable
|
|
111
|
+
* implementation can rebuild the queue after a restart. It is not a broker:
|
|
112
|
+
* the service still owns scheduling, retries, and handlers, and two processes
|
|
113
|
+
* sharing one store both read the same backlog.
|
|
114
|
+
*/
|
|
115
|
+
interface QueueStore {
|
|
116
|
+
/** Every job the store currently holds, pending, running, or dead-lettered. */
|
|
117
|
+
load(): readonly QueueJob[] | PromiseLike<readonly QueueJob[]>;
|
|
118
|
+
/** Records one job's latest state. */
|
|
119
|
+
save(job: QueueJob): void | PromiseLike<void>;
|
|
120
|
+
/** Removes one job that completed or was cleared. */
|
|
121
|
+
remove(id: string): void | PromiseLike<void>;
|
|
122
|
+
/** Removes every job. */
|
|
123
|
+
clear(): void | PromiseLike<void>;
|
|
124
|
+
}
|
|
125
|
+
/** Registration options for one queue. */
|
|
126
|
+
interface QueueServiceOptions {
|
|
127
|
+
/** How many jobs may run at once; defaults to 1. */
|
|
128
|
+
readonly concurrency?: number;
|
|
129
|
+
/** The default attempt budget; defaults to 3. */
|
|
130
|
+
readonly maxAttempts?: number;
|
|
131
|
+
/** The first retry delay; each following delay doubles; defaults to 100 ms. */
|
|
132
|
+
readonly backoffMs?: number;
|
|
133
|
+
/** The retry delay ceiling; defaults to 30 seconds. */
|
|
134
|
+
readonly maxBackoffMs?: number;
|
|
135
|
+
/** How many jobs may wait at once; defaults to 1000. */
|
|
136
|
+
readonly maxJobs?: number;
|
|
137
|
+
/**
|
|
138
|
+
* How many failed jobs may be retained; defaults to `maxJobs`.
|
|
139
|
+
*
|
|
140
|
+
* Dead letters keep their payloads, so this is a memory bound rather than a
|
|
141
|
+
* retention policy. The oldest dead letter is evicted when the map is full.
|
|
142
|
+
*/
|
|
143
|
+
readonly maxDeadLetters?: number;
|
|
144
|
+
/** How long one attempt may run; `0` means no limit and is the default. */
|
|
145
|
+
readonly jobTimeoutMs?: number;
|
|
146
|
+
/** Whether `enqueue` schedules draining itself; defaults to true. */
|
|
147
|
+
readonly autoStart?: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* The backlog the queue keeps outside its memory.
|
|
150
|
+
*
|
|
151
|
+
* The default is memory only. A durable store rebuilds the pending jobs and
|
|
152
|
+
* the dead letters when the module initializes; `flush()` waits for the
|
|
153
|
+
* writes the service has started.
|
|
154
|
+
*/
|
|
155
|
+
readonly store?: QueueStore;
|
|
156
|
+
/** The clock retry delay and availability read; defaults to `Date.now`. */
|
|
157
|
+
readonly now?: () => number;
|
|
158
|
+
/** The timer background draining uses. */
|
|
159
|
+
readonly timer?: QueueTimer;
|
|
160
|
+
/** Called with a failed attempt; defaults to silence. */
|
|
161
|
+
readonly onError?: (error: unknown, job: QueueJob<unknown>) => void;
|
|
162
|
+
}
|
|
163
|
+
/** Options `QueueModule.register` accepts. */
|
|
164
|
+
interface QueueModuleOptions {
|
|
165
|
+
readonly queue?: QueueServiceOptions;
|
|
166
|
+
/** The outbox registration; defaults apply when it is absent. */
|
|
167
|
+
readonly outbox?: OutboxOptions;
|
|
168
|
+
}
|
|
169
|
+
/** The registration options a factory supplies. */
|
|
170
|
+
type QueueModuleAsyncOptions = ModuleAsyncOptions<QueueModuleOptions>;
|
|
171
|
+
/**
|
|
172
|
+
* Options that shape the module definition rather than the injected queue
|
|
173
|
+
* options, mirroring the `isGlobal` extra every Nest configurable module states.
|
|
174
|
+
*/
|
|
175
|
+
interface QueueModuleExtras {
|
|
176
|
+
/** Makes the registration's exports visible without an import. Defaults to false. */
|
|
177
|
+
readonly isGlobal?: boolean;
|
|
178
|
+
/** The queue name `@InjectQueue()` resolves; defaults to `default`. */
|
|
179
|
+
readonly name?: string;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* The generated registration class, options token, and type markers.
|
|
183
|
+
*
|
|
184
|
+
* `MODULE_OPTIONS_TOKEN` is the `QUEUE_MODULE_OPTIONS` token; `OPTIONS_TYPE` and
|
|
185
|
+
* `ASYNC_OPTIONS_TYPE` are type markers that throw when read as values.
|
|
186
|
+
*/
|
|
187
|
+
declare const ConfigurableModuleClass: import("@aponiajs/common").ConfigurableModuleClass<QueueModuleOptions, "register", "create", QueueModuleExtras>, OPTIONS_TYPE: QueueModuleOptions & Partial<QueueModuleExtras>, ASYNC_OPTIONS_TYPE: ConfigurableModuleAsyncOptions<QueueModuleOptions, "create"> & Partial<QueueModuleExtras>;
|
|
188
|
+
/** The options token, narrowed to the explicit token the builder mints. */
|
|
189
|
+
export declare const MODULE_OPTIONS_TOKEN: InjectionToken<QueueModuleOptions>;
|
|
190
|
+
/** The synchronous registration's parameter type. */
|
|
191
|
+
type QueueModuleSyncOptions = QueueModuleOptions & QueueModuleExtras;
|
|
192
|
+
/** The asynchronous registration's parameter type. */
|
|
193
|
+
type QueueModuleRegistrationAsyncOptions = ConfigurableModuleAsyncOptions<QueueModuleOptions> & Partial<QueueModuleExtras>;
|
|
194
|
+
/**
|
|
195
|
+
* Provides the in-process job queue and the transactional outbox.
|
|
196
|
+
*
|
|
197
|
+
* The registration is one module, so `application.get(QueueService)` reads the
|
|
198
|
+
* queue the application declared. Two registrations are distinct modules.
|
|
199
|
+
*/
|
|
200
|
+
export declare class QueueModule extends ConfigurableModuleClass {
|
|
201
|
+
/**
|
|
202
|
+
* Builds one queue registration.
|
|
203
|
+
*
|
|
204
|
+
* Both the queue and the outbox options are validated at registration, so a
|
|
205
|
+
* malformed bound or store fails before the module is imported.
|
|
206
|
+
*
|
|
207
|
+
* @param options - The queue and outbox options, and the queue name.
|
|
208
|
+
* @returns A frozen dynamic module an application imports.
|
|
209
|
+
* @throws An `AponiaError` with `INVALID_QUEUE_OPTIONS` when an option is invalid.
|
|
210
|
+
*/
|
|
211
|
+
static forRoot(options?: QueueModuleSyncOptions): DynamicModule;
|
|
212
|
+
/**
|
|
213
|
+
* Builds a queue registration whose options a factory, a class, or an
|
|
214
|
+
* existing provider resolves.
|
|
215
|
+
*
|
|
216
|
+
* The options are resolved once when the options token first resolves, and
|
|
217
|
+
* validated then, so a refused boot names the same issues `forRoot` reports.
|
|
218
|
+
*
|
|
219
|
+
* @param options - The imports, injected tokens, factory, extras, and extra providers.
|
|
220
|
+
* @returns A frozen dynamic module an application imports.
|
|
221
|
+
*/
|
|
222
|
+
static forRootAsync(options: QueueModuleRegistrationAsyncOptions): DynamicModule;
|
|
223
|
+
/**
|
|
224
|
+
* Builds one queue registration.
|
|
225
|
+
*
|
|
226
|
+
* @deprecated Use {@link QueueModule.forRoot}; retained for the beta line.
|
|
227
|
+
*/
|
|
228
|
+
static register(options?: QueueModuleSyncOptions): DynamicModule;
|
|
229
|
+
/**
|
|
230
|
+
* Builds a queue registration whose options a factory resolves.
|
|
231
|
+
*
|
|
232
|
+
* @deprecated Use {@link QueueModule.forRootAsync}; retained for the beta line.
|
|
233
|
+
*/
|
|
234
|
+
static registerAsync(options: QueueModuleRegistrationAsyncOptions): DynamicModule;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* The token a named queue is injectable under.
|
|
238
|
+
*
|
|
239
|
+
* `@nestjs/bullmq` spells this `BullQueue_<name>`; this package names its
|
|
240
|
+
* in-process queue registration instead, and never presents the token as a
|
|
241
|
+
* broker queue.
|
|
242
|
+
*
|
|
243
|
+
* @param name - The registration's name; omitted is the default queue.
|
|
244
|
+
* @returns The injection token.
|
|
245
|
+
*/
|
|
246
|
+
export declare function getQueueToken(name?: string): string;
|
|
247
|
+
/**
|
|
248
|
+
* Injects the in-process queue a registration provides.
|
|
249
|
+
*
|
|
250
|
+
* @param name - The registration's name; omitted is the default queue.
|
|
251
|
+
* @returns The parameter decorator.
|
|
252
|
+
*/
|
|
253
|
+
export declare const InjectQueue: (name?: string) => ReturnType<typeof Inject>;
|
|
254
|
+
/** Options `@Processor()` accepts. */
|
|
255
|
+
interface ProcessorOptions {
|
|
256
|
+
/** The job name this processor handles; defaults to `default`. */
|
|
257
|
+
readonly name?: string;
|
|
258
|
+
/** Accepted for `@nestjs/bullmq` compatibility; this package ignores it. */
|
|
259
|
+
readonly scope?: unknown;
|
|
260
|
+
/** Accepted for `@nestjs/bullmq` compatibility; this package ignores it. */
|
|
261
|
+
readonly configKey?: string;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Marks a `WorkerHost` as the processor for one job name.
|
|
265
|
+
*
|
|
266
|
+
* The in-process queue runs a handler per job name, so the processor's `name`
|
|
267
|
+
* is the job name it handles — there is no broker queue to subscribe to.
|
|
268
|
+
*
|
|
269
|
+
* @param queueNameOrOptions - A job name or processor options.
|
|
270
|
+
* @returns The class decorator.
|
|
271
|
+
* @throws A `TypeError` when the name is empty.
|
|
272
|
+
*/
|
|
273
|
+
export declare function Processor(queueNameOrOptions?: string | ProcessorOptions): ClassDecorator;
|
|
274
|
+
/**
|
|
275
|
+
* The base class a `@Processor()` implements.
|
|
276
|
+
*
|
|
277
|
+
* `@nestjs/bullmq`'s `WorkerHost` exposes a BullMQ `Worker` and an abstract
|
|
278
|
+
* `process(job)`. This package has no broker worker: `process` receives the
|
|
279
|
+
* in-process queue's frozen job snapshot, and `worker` refuses rather than
|
|
280
|
+
* inventing one.
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* ```ts
|
|
284
|
+
* @Processor("email")
|
|
285
|
+
* class EmailProcessor extends WorkerHost {
|
|
286
|
+
* async process(job: QueueJob<{ to: string }>): Promise<void> { ... }
|
|
287
|
+
* }
|
|
288
|
+
* ```
|
|
289
|
+
*/
|
|
290
|
+
export declare abstract class WorkerHost<TJob extends QueueJob = QueueJob> {
|
|
291
|
+
/**
|
|
292
|
+
* The broker worker, which this package does not have.
|
|
293
|
+
*
|
|
294
|
+
* @throws An `AponiaError` with `INVALID_QUEUE_JOB`; use the `process(job)`
|
|
295
|
+
* argument.
|
|
296
|
+
*/
|
|
297
|
+
get worker(): never;
|
|
298
|
+
/** Handles one job snapshot. */
|
|
299
|
+
abstract process(job: TJob, token?: string): unknown;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* The current job inside a processor.
|
|
303
|
+
*
|
|
304
|
+
* `@nestjs/bullmq` aliases this token to its request-scoped `REQUEST`, so a
|
|
305
|
+
* provider injected into a processor can read the job being handled. This
|
|
306
|
+
* package has no per-job request scope, so the value here is a forwarding view:
|
|
307
|
+
* its properties read the job the queue is running in the current async chain,
|
|
308
|
+
* and they are `undefined` outside a handler.
|
|
309
|
+
*/
|
|
310
|
+
export declare const JOB_REF: import("@aponiajs/common").InjectionToken<QueueJob<unknown>>;
|
|
311
|
+
/** Holds the job a processor is handling for the current async chain. */
|
|
312
|
+
export declare class JobRefService {
|
|
313
|
+
#private;
|
|
314
|
+
/** The job the current async chain is handling, if any. */
|
|
315
|
+
current(): QueueJob | undefined;
|
|
316
|
+
/** @internal Runs one handler with its job as the ambient value. */
|
|
317
|
+
run<T>(job: QueueJob, work: () => T): T;
|
|
318
|
+
/**
|
|
319
|
+
* The value `JOB_REF` resolves to.
|
|
320
|
+
*
|
|
321
|
+
* `@nestjs/bullmq` injects the job directly. A forwarding view keeps that
|
|
322
|
+
* shape: reading `job.id`, `job.name`, or `job.payload` answers the job the
|
|
323
|
+
* current async chain is handling, and nothing outside a handler.
|
|
324
|
+
*/
|
|
325
|
+
proxy(): QueueJob;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* An in-process job queue with bounded retries, exponential backoff, a dead
|
|
329
|
+
* letter queue, and idempotent enqueue.
|
|
330
|
+
*
|
|
331
|
+
* The queue is process-local. It survives no restart and shares no state with
|
|
332
|
+
* another application instance; a deployment that needs either needs a broker.
|
|
333
|
+
*/
|
|
334
|
+
export declare class QueueService implements OnModuleDestroy, OnModuleInit {
|
|
335
|
+
#private;
|
|
336
|
+
/** @internal Construct through `QueueModule.register`. */
|
|
337
|
+
constructor(options?: QueueServiceOptions, jobRef?: JobRefService);
|
|
338
|
+
/** Registers the handler one job name runs. A later call replaces it. */
|
|
339
|
+
registerHandler<TPayload>(name: string, handler: QueueHandler<TPayload>): void;
|
|
340
|
+
/** Adds one job and returns a frozen snapshot of it. */
|
|
341
|
+
enqueue<TPayload>(name: string, payload: TPayload, options?: QueueEnqueueOptions): QueueJob<TPayload>;
|
|
342
|
+
/** Runs every job whose next attempt is due, in batches of the concurrency. */
|
|
343
|
+
drain(): Promise<QueueDrainSummary>;
|
|
344
|
+
/** Resolves once nothing is running and no pending job is due right now. */
|
|
345
|
+
waitForIdle(): Promise<void>;
|
|
346
|
+
/** The pending and running jobs. */
|
|
347
|
+
pending(): readonly QueueJob[];
|
|
348
|
+
/** The jobs that exhausted their attempt budget. */
|
|
349
|
+
deadLetters(): readonly QueueJob[];
|
|
350
|
+
/** Moves one dead letter back to pending with a fresh attempt budget. */
|
|
351
|
+
retryDeadLetter(id: string): QueueJob;
|
|
352
|
+
/** The current job counts. */
|
|
353
|
+
stats(): QueueStats;
|
|
354
|
+
/** Stops background draining. Later `enqueue` calls refuse. */
|
|
355
|
+
close(): void;
|
|
356
|
+
/** Stops automatic draining; an explicit `drain()` still runs. */
|
|
357
|
+
pause(): void;
|
|
358
|
+
/** Resumes automatic draining after `pause()`. */
|
|
359
|
+
resume(): void;
|
|
360
|
+
/** Whether automatic draining is paused. */
|
|
361
|
+
get paused(): boolean;
|
|
362
|
+
/** Drops every job, dead letter, and idempotency key. */
|
|
363
|
+
clear(): void;
|
|
364
|
+
/** Awaits the writes the store has accepted, and rethrows the first failure. */
|
|
365
|
+
flush(): Promise<void>;
|
|
366
|
+
/** @internal Rebuilds the backlog a store holds when the module initializes. */
|
|
367
|
+
onModuleInit(): Promise<void>;
|
|
368
|
+
/** @internal The module destroy hook stops background work. */
|
|
369
|
+
onModuleDestroy(): Promise<void>;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Records messages inside the transaction boundary and delivers them after it.
|
|
373
|
+
*
|
|
374
|
+
* The built-in outbox is process-local: a restart loses it, and two instances
|
|
375
|
+
* keep separate outboxes. It records intent, not durable state.
|
|
376
|
+
*/
|
|
377
|
+
export declare class OutboxService {
|
|
378
|
+
#private;
|
|
379
|
+
constructor(options?: OutboxOptions);
|
|
380
|
+
/** Records one message and returns its frozen form. */
|
|
381
|
+
record<TPayload>(name: string, payload: TPayload): OutboxMessage<TPayload>;
|
|
382
|
+
/** The recorded messages, oldest first. */
|
|
383
|
+
pending(): readonly OutboxMessage[];
|
|
384
|
+
/**
|
|
385
|
+
* Delivers recorded messages in order and removes the ones the sink accepted.
|
|
386
|
+
* A rejected message stays at the front of the outbox for the next flush.
|
|
387
|
+
*/
|
|
388
|
+
flush(sink: OutboxSink, options?: OutboxFlushOptions): Promise<OutboxFlushResult>;
|
|
389
|
+
/** Drops every recorded message. */
|
|
390
|
+
clear(): void;
|
|
391
|
+
}
|
|
392
|
+
/** Options for one SQLite-backed outbox store. */
|
|
393
|
+
interface SqliteOutboxStoreOptions {
|
|
394
|
+
/** The open database the store owns its table in. */
|
|
395
|
+
readonly database: Database;
|
|
396
|
+
/** The table name; defaults to `aponia_outbox`. */
|
|
397
|
+
readonly table?: string;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* A durable outbox over SQLite.
|
|
401
|
+
*
|
|
402
|
+
* The application owns the database and its file; this class owns one table and
|
|
403
|
+
* creates it if it is absent. Payloads are stored as JSON, so a value that
|
|
404
|
+
* `JSON.stringify` cannot state is stored as `null` rather than losing the
|
|
405
|
+
* message.
|
|
406
|
+
*/
|
|
407
|
+
export declare class SqliteOutboxStore implements OutboxStore {
|
|
408
|
+
#private;
|
|
409
|
+
constructor(options: SqliteOutboxStoreOptions);
|
|
410
|
+
list(): readonly OutboxMessage[];
|
|
411
|
+
append(message: OutboxMessage): void;
|
|
412
|
+
update(message: OutboxMessage): void;
|
|
413
|
+
remove(id: string): void;
|
|
414
|
+
clear(): void;
|
|
415
|
+
}
|
|
416
|
+
/** A bounded in-memory backlog, for tests and single-process durability checks. */
|
|
417
|
+
export declare class MemoryQueueStore implements QueueStore {
|
|
418
|
+
#private;
|
|
419
|
+
constructor(options?: {
|
|
420
|
+
readonly maxJobs?: number;
|
|
421
|
+
});
|
|
422
|
+
load(): readonly QueueJob[];
|
|
423
|
+
save(job: QueueJob): void;
|
|
424
|
+
remove(id: string): void;
|
|
425
|
+
clear(): void;
|
|
426
|
+
}
|
|
427
|
+
export type { OutboxFlushResult, OutboxMessage, OutboxOptions, OutboxSink, OutboxStore, ProcessorOptions, QueueDrainSummary, QueueEnqueueOptions, QueueHandler, QueueJob, QueueJobState, QueueModuleAsyncOptions, QueueModuleExtras, QueueModuleOptions, QueueModuleRegistrationAsyncOptions, QueueModuleSyncOptions, QueueServiceOptions, QueueStats, QueueStore, QueueTimer, SqliteOutboxStoreOptions };
|