glide-mq 0.1.0
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 +190 -0
- package/dist/connection.d.ts +36 -0
- package/dist/connection.d.ts.map +1 -0
- package/dist/connection.js +100 -0
- package/dist/connection.js.map +1 -0
- package/dist/errors.d.ts +10 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +25 -0
- package/dist/errors.js.map +1 -0
- package/dist/flow-producer.d.ts +36 -0
- package/dist/flow-producer.d.ts.map +1 -0
- package/dist/flow-producer.js +185 -0
- package/dist/flow-producer.js.map +1 -0
- package/dist/functions/index.d.ts +136 -0
- package/dist/functions/index.d.ts.map +1 -0
- package/dist/functions/index.js +1062 -0
- package/dist/functions/index.js.map +1 -0
- package/dist/graceful-shutdown.d.ts +17 -0
- package/dist/graceful-shutdown.d.ts.map +1 -0
- package/dist/graceful-shutdown.js +27 -0
- package/dist/graceful-shutdown.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/job.d.ts +106 -0
- package/dist/job.d.ts.map +1 -0
- package/dist/job.js +252 -0
- package/dist/job.js.map +1 -0
- package/dist/queue-events.d.ts +33 -0
- package/dist/queue-events.d.ts.map +1 -0
- package/dist/queue-events.js +138 -0
- package/dist/queue-events.js.map +1 -0
- package/dist/queue.d.ts +140 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +483 -0
- package/dist/queue.js.map +1 -0
- package/dist/scheduler.d.ts +48 -0
- package/dist/scheduler.d.ts.map +1 -0
- package/dist/scheduler.js +140 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/telemetry.d.ts +29 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +90 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/types.d.ts +125 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +65 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +217 -0
- package/dist/utils.js.map +1 -0
- package/dist/worker.d.ts +138 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +574 -0
- package/dist/worker.js.map +1 -0
- package/dist/workflows.d.ts +34 -0
- package/dist/workflows.d.ts.map +1 -0
- package/dist/workflows.js +117 -0
- package/dist/workflows.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QueueEvents = void 0;
|
|
4
|
+
const events_1 = require("events");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
|
+
const connection_1 = require("./connection");
|
|
7
|
+
class QueueEvents extends events_1.EventEmitter {
|
|
8
|
+
name;
|
|
9
|
+
opts;
|
|
10
|
+
client = null;
|
|
11
|
+
queueKeys;
|
|
12
|
+
running = false;
|
|
13
|
+
closing = false;
|
|
14
|
+
lastId;
|
|
15
|
+
initPromise;
|
|
16
|
+
blockTimeout;
|
|
17
|
+
reconnectBackoff = 0;
|
|
18
|
+
constructor(name, opts) {
|
|
19
|
+
super();
|
|
20
|
+
this.name = name;
|
|
21
|
+
this.opts = opts;
|
|
22
|
+
this.queueKeys = (0, utils_1.buildKeys)(name, opts.prefix);
|
|
23
|
+
// '$' means only new messages from this point forward
|
|
24
|
+
this.lastId = opts.lastEventId ?? '$';
|
|
25
|
+
this.blockTimeout = opts.blockTimeout ?? 5000;
|
|
26
|
+
this.initPromise = this.init();
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Wait until the QueueEvents instance is connected and listening.
|
|
30
|
+
*/
|
|
31
|
+
async waitUntilReady() {
|
|
32
|
+
return this.initPromise;
|
|
33
|
+
}
|
|
34
|
+
async init() {
|
|
35
|
+
this.client = await (0, connection_1.createBlockingClient)(this.opts.connection);
|
|
36
|
+
await (0, connection_1.ensureFunctionLibrary)(this.client, undefined, this.opts.connection.clusterMode ?? false);
|
|
37
|
+
this.running = true;
|
|
38
|
+
this.pollLoop();
|
|
39
|
+
}
|
|
40
|
+
pollLoop() {
|
|
41
|
+
if (!this.running || this.closing)
|
|
42
|
+
return;
|
|
43
|
+
this.pollOnce()
|
|
44
|
+
.then(() => {
|
|
45
|
+
this.reconnectBackoff = 0;
|
|
46
|
+
this.pollLoop();
|
|
47
|
+
})
|
|
48
|
+
.catch((err) => {
|
|
49
|
+
if (this.running && !this.closing) {
|
|
50
|
+
this.emit('error', err);
|
|
51
|
+
this.reconnectBackoff = (0, utils_1.nextReconnectDelay)(this.reconnectBackoff);
|
|
52
|
+
setTimeout(() => this.reconnectAndResume(), this.reconnectBackoff);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
reconnectCtx = {
|
|
57
|
+
isActive: () => this.running && !this.closing,
|
|
58
|
+
getBackoff: () => this.reconnectBackoff,
|
|
59
|
+
setBackoff: (ms) => { this.reconnectBackoff = ms; },
|
|
60
|
+
onError: (err) => { this.emit('error', err); },
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Attempt to reconnect the client and resume polling after a connection error.
|
|
64
|
+
*/
|
|
65
|
+
async reconnectAndResume() {
|
|
66
|
+
await (0, utils_1.reconnectWithBackoff)(this.reconnectCtx, async () => {
|
|
67
|
+
if (this.client) {
|
|
68
|
+
try {
|
|
69
|
+
this.client.close();
|
|
70
|
+
}
|
|
71
|
+
catch { /* ignore */ }
|
|
72
|
+
this.client = null;
|
|
73
|
+
}
|
|
74
|
+
this.client = await (0, connection_1.createBlockingClient)(this.opts.connection);
|
|
75
|
+
await (0, connection_1.ensureFunctionLibrary)(this.client, undefined, this.opts.connection.clusterMode ?? false);
|
|
76
|
+
}, () => this.pollLoop());
|
|
77
|
+
}
|
|
78
|
+
async pollOnce() {
|
|
79
|
+
if (!this.client || !this.running)
|
|
80
|
+
return;
|
|
81
|
+
// XREAD BLOCK {blockTimeout} COUNT 100 STREAMS {eventsKey} {lastId}
|
|
82
|
+
const result = await this.client.xread({ [this.queueKeys.events]: this.lastId }, { block: this.blockTimeout, count: 100 });
|
|
83
|
+
if (!result) {
|
|
84
|
+
// Timeout with no new entries - loop again
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
// result: GlideRecord<StreamEntryDataType>
|
|
88
|
+
// i.e. { key, value }[] where value = Record<entryId, [GlideString, GlideString][]>
|
|
89
|
+
for (const streamEntry of result) {
|
|
90
|
+
const entries = streamEntry.value;
|
|
91
|
+
for (const [entryId, fieldPairs] of Object.entries(entries)) {
|
|
92
|
+
if (!fieldPairs)
|
|
93
|
+
continue;
|
|
94
|
+
// Parse field pairs into a map
|
|
95
|
+
const fields = {};
|
|
96
|
+
for (const [f, v] of fieldPairs) {
|
|
97
|
+
fields[String(f)] = String(v);
|
|
98
|
+
}
|
|
99
|
+
const eventType = fields.event;
|
|
100
|
+
if (!eventType)
|
|
101
|
+
continue;
|
|
102
|
+
// Build the event payload: always include jobId, plus any extra fields
|
|
103
|
+
const payload = {};
|
|
104
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
105
|
+
if (key === 'event')
|
|
106
|
+
continue; // don't include the event type in payload
|
|
107
|
+
payload[key] = value;
|
|
108
|
+
}
|
|
109
|
+
this.emit(eventType, payload);
|
|
110
|
+
// Update lastId to this entry so we don't re-read it
|
|
111
|
+
this.lastId = String(entryId);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Close the QueueEvents listener.
|
|
117
|
+
* Idempotent: safe to call multiple times.
|
|
118
|
+
*/
|
|
119
|
+
async close() {
|
|
120
|
+
if (this.closing)
|
|
121
|
+
return;
|
|
122
|
+
this.closing = true;
|
|
123
|
+
this.running = false;
|
|
124
|
+
// Wait for init to complete so client is available for cleanup
|
|
125
|
+
try {
|
|
126
|
+
await this.initPromise;
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
// init may have failed - that's fine
|
|
130
|
+
}
|
|
131
|
+
if (this.client) {
|
|
132
|
+
this.client.close();
|
|
133
|
+
this.client = null;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.QueueEvents = QueueEvents;
|
|
138
|
+
//# sourceMappingURL=queue-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue-events.js","sourceRoot":"","sources":["../src/queue-events.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AAEtC,mCAA8E;AAC9E,6CAA2E;AAE3E,MAAa,WAAY,SAAQ,qBAAY;IAClC,IAAI,CAAS;IACd,IAAI,CAAqB;IACzB,MAAM,GAAkB,IAAI,CAAC;IAC7B,SAAS,CAA+B;IACxC,OAAO,GAAG,KAAK,CAAC;IAChB,OAAO,GAAG,KAAK,CAAC;IAChB,MAAM,CAAS;IACf,WAAW,CAAgB;IAC3B,YAAY,CAAS;IACrB,gBAAgB,GAAG,CAAC,CAAC;IAE7B,YAAY,IAAY,EAAE,IAAwB;QAChD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,IAAA,iBAAS,EAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC9C,sDAAsD;QACtD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,WAAW,IAAI,GAAG,CAAC;QACtC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC;QAC9C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,cAAc;QAClB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAEO,KAAK,CAAC,IAAI;QAChB,IAAI,CAAC,M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AAC;QAAC,MAAM,CAAC;YACP,qCAAqC;QACvC,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACrB,CAAC;IACH,CAAC;CACF;AAxJD,kCAwJC"}
|
package/dist/queue.d.ts
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
import type { QueueOptions, JobOptions, Client, ScheduleOpts, JobTemplate, SchedulerEntry, Metrics, JobCounts } from './types';
|
|
3
|
+
import { Job } from './job';
|
|
4
|
+
export declare class Queue<D = any, R = any> extends EventEmitter {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
private opts;
|
|
7
|
+
private client;
|
|
8
|
+
private closing;
|
|
9
|
+
private keys;
|
|
10
|
+
constructor(name: string, opts: QueueOptions);
|
|
11
|
+
/** @internal */
|
|
12
|
+
getClient(): Promise<Client>;
|
|
13
|
+
/**
|
|
14
|
+
* Add a single job to the queue.
|
|
15
|
+
* Uses the glidemq_addJob server function to atomically create the job hash
|
|
16
|
+
* and enqueue it to the stream (or scheduled ZSet if delayed/prioritized).
|
|
17
|
+
*/
|
|
18
|
+
add(name: string, data: D, opts?: JobOptions): Promise<Job<D, R> | null>;
|
|
19
|
+
/**
|
|
20
|
+
* Add multiple jobs to the queue in a pipeline.
|
|
21
|
+
* Each job is added via a separate addJob FCALL (non-atomic across jobs).
|
|
22
|
+
*/
|
|
23
|
+
addBulk(jobs: {
|
|
24
|
+
name: string;
|
|
25
|
+
data: D;
|
|
26
|
+
opts?: JobOptions;
|
|
27
|
+
}[]): Promise<Job<D, R>[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Retrieve a job by ID from the queue.
|
|
30
|
+
* Returns null if the job does not exist.
|
|
31
|
+
*/
|
|
32
|
+
getJob(id: string): Promise<Job<D, R> | null>;
|
|
33
|
+
/**
|
|
34
|
+
* Pause the queue. Workers will stop picking up new jobs.
|
|
35
|
+
*/
|
|
36
|
+
pause(): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Resume the queue after a pause.
|
|
39
|
+
*/
|
|
40
|
+
resume(): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Revoke a job by ID.
|
|
43
|
+
* If the job is waiting/delayed, it is immediately moved to the failed set with reason 'revoked'.
|
|
44
|
+
* If the job is currently being processed, a revoked flag is set on the hash -
|
|
45
|
+
* the worker will check this flag cooperatively and fire the AbortSignal.
|
|
46
|
+
* Returns 'revoked', 'flagged', or 'not_found'.
|
|
47
|
+
*/
|
|
48
|
+
revoke(jobId: string): Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* Set the global concurrency limit for this queue.
|
|
51
|
+
* When set, workers will not pick up new jobs if the total number of
|
|
52
|
+
* pending (active) jobs across all workers meets or exceeds this limit.
|
|
53
|
+
* Set to 0 to remove the limit.
|
|
54
|
+
*/
|
|
55
|
+
setGlobalConcurrency(n: number): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Upsert a job scheduler (repeatable/cron job).
|
|
58
|
+
* Stores the scheduler config in the schedulers hash.
|
|
59
|
+
* Computes the initial nextRun based on the schedule.
|
|
60
|
+
*/
|
|
61
|
+
upsertJobScheduler(name: string, schedule: ScheduleOpts, template?: JobTemplate): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Remove a job scheduler by name.
|
|
64
|
+
*/
|
|
65
|
+
removeJobScheduler(name: string): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Get metrics for completed or failed jobs.
|
|
68
|
+
* Returns the count of entries in the corresponding ZSet.
|
|
69
|
+
*/
|
|
70
|
+
getMetrics(type: 'completed' | 'failed'): Promise<Metrics>;
|
|
71
|
+
/**
|
|
72
|
+
* Get job counts by state.
|
|
73
|
+
* - waiting: stream length minus active (pending) entries
|
|
74
|
+
* - active: PEL count from XPENDING
|
|
75
|
+
* - delayed: scheduled ZSet cardinality (includes both delayed and prioritized)
|
|
76
|
+
* - completed: completed ZSet cardinality
|
|
77
|
+
* - failed: failed ZSet cardinality
|
|
78
|
+
*/
|
|
79
|
+
getJobCounts(): Promise<JobCounts>;
|
|
80
|
+
/**
|
|
81
|
+
* Remove all data associated with this queue from the server.
|
|
82
|
+
* If force=false (default), fails if there are active jobs.
|
|
83
|
+
* If force=true, deletes everything regardless of active jobs.
|
|
84
|
+
*/
|
|
85
|
+
obliterate(opts?: {
|
|
86
|
+
force?: boolean;
|
|
87
|
+
}): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Scan for keys matching a pattern and delete them in batches.
|
|
90
|
+
* Handles both standalone (GlideClient) and cluster (GlideClusterClient) scan APIs.
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
93
|
+
private scanAndDelete;
|
|
94
|
+
/**
|
|
95
|
+
* Retrieve jobs by state with optional pagination.
|
|
96
|
+
* @param type - The job state to query
|
|
97
|
+
* @param start - Start index for pagination (default 0)
|
|
98
|
+
* @param end - End index for pagination (default -1, meaning all)
|
|
99
|
+
*/
|
|
100
|
+
getJobs(type: 'waiting' | 'active' | 'delayed' | 'completed' | 'failed', start?: number, end?: number): Promise<Job<D, R>[]>;
|
|
101
|
+
/**
|
|
102
|
+
* Get job counts by types. Alias for getJobCounts().
|
|
103
|
+
*/
|
|
104
|
+
getJobCountByTypes(): Promise<JobCounts>;
|
|
105
|
+
/**
|
|
106
|
+
* Check if the queue is paused.
|
|
107
|
+
*/
|
|
108
|
+
isPaused(): Promise<boolean>;
|
|
109
|
+
/**
|
|
110
|
+
* Get the count of waiting jobs (stream length).
|
|
111
|
+
*/
|
|
112
|
+
count(): Promise<number>;
|
|
113
|
+
/**
|
|
114
|
+
* Get all registered job schedulers (repeatable jobs).
|
|
115
|
+
*/
|
|
116
|
+
getRepeatableJobs(): Promise<{
|
|
117
|
+
name: string;
|
|
118
|
+
entry: SchedulerEntry;
|
|
119
|
+
}[]>;
|
|
120
|
+
/**
|
|
121
|
+
* Retrieve log entries for a job by ID.
|
|
122
|
+
*/
|
|
123
|
+
getJobLogs(id: string, start?: number, end?: number): Promise<{
|
|
124
|
+
logs: string[];
|
|
125
|
+
count: number;
|
|
126
|
+
}>;
|
|
127
|
+
/**
|
|
128
|
+
* Retrieve jobs from the dead letter queue configured for this queue.
|
|
129
|
+
* Returns an empty array if no DLQ is configured.
|
|
130
|
+
* @param start - Start index (default 0)
|
|
131
|
+
* @param end - End index (default -1, meaning all)
|
|
132
|
+
*/
|
|
133
|
+
getDeadLetterJobs(start?: number, end?: number): Promise<Job<D, R>[]>;
|
|
134
|
+
/**
|
|
135
|
+
* Close the queue and release the underlying client connection.
|
|
136
|
+
* Idempotent: safe to call multiple times.
|
|
137
|
+
*/
|
|
138
|
+
close(): Promise<void>;
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC/H,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAe5B,qBAAa,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,CAAE,SAAQ,YAAY;IACvD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,IAAI,CAAe;IAC3B,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,IAAI,CAAY;gBAEZ,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY;IAO5C,gBAAgB;IACV,SAAS,IAAI,OAAO,C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