@deenruv/job-queue-plugin 1.0.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/LICENSE +23 -0
- package/README.md +94 -0
- package/package/bullmq/bullmq-job-queue-strategy.d.ts +39 -0
- package/package/bullmq/bullmq-job-queue-strategy.js +362 -0
- package/package/bullmq/bullmq-job-queue-strategy.js.map +1 -0
- package/package/bullmq/constants.d.ts +4 -0
- package/package/bullmq/constants.js +16 -0
- package/package/bullmq/constants.js.map +1 -0
- package/package/bullmq/index.d.ts +2 -0
- package/package/bullmq/index.js +27 -0
- package/package/bullmq/index.js.map +1 -0
- package/package/bullmq/plugin.d.ts +133 -0
- package/package/bullmq/plugin.js +171 -0
- package/package/bullmq/plugin.js.map +1 -0
- package/package/bullmq/redis-health-check-strategy.d.ts +6 -0
- package/package/bullmq/redis-health-check-strategy.js +15 -0
- package/package/bullmq/redis-health-check-strategy.js.map +1 -0
- package/package/bullmq/redis-health-indicator.d.ts +8 -0
- package/package/bullmq/redis-health-indicator.js +80 -0
- package/package/bullmq/redis-health-indicator.js.map +1 -0
- package/package/bullmq/redis-job-buffer-storage-strategy.d.ts +16 -0
- package/package/bullmq/redis-job-buffer-storage-strategy.js +82 -0
- package/package/bullmq/redis-job-buffer-storage-strategy.js.map +1 -0
- package/package/bullmq/scripts/get-jobs-by-type.d.ts +10 -0
- package/package/bullmq/scripts/get-jobs-by-type.js +114 -0
- package/package/bullmq/scripts/get-jobs-by-type.js.map +1 -0
- package/package/bullmq/types.d.ts +101 -0
- package/package/bullmq/types.js +3 -0
- package/package/bullmq/types.js.map +1 -0
- package/package/index.d.ts +4 -0
- package/package/index.js +8 -0
- package/package/index.js.map +1 -0
- package/package/pub-sub/constants.d.ts +2 -0
- package/package/pub-sub/constants.js +6 -0
- package/package/pub-sub/constants.js.map +1 -0
- package/package/pub-sub/index.d.ts +2 -0
- package/package/pub-sub/index.js +19 -0
- package/package/pub-sub/index.js.map +1 -0
- package/package/pub-sub/options.d.ts +13 -0
- package/package/pub-sub/options.js +3 -0
- package/package/pub-sub/options.js.map +1 -0
- package/package/pub-sub/plugin.d.ts +6 -0
- package/package/pub-sub/plugin.js +36 -0
- package/package/pub-sub/plugin.js.map +1 -0
- package/package/pub-sub/pub-sub-job-queue-strategy.d.ts +16 -0
- package/package/pub-sub/pub-sub-job-queue-strategy.js +123 -0
- package/package/pub-sub/pub-sub-job-queue-strategy.js.map +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Job } from "@deenruv/core";
|
|
2
|
+
import { ConnectionOptions, WorkerOptions } from "bullmq";
|
|
3
|
+
import { QueueOptions } from "bullmq";
|
|
4
|
+
/**
|
|
5
|
+
* @description
|
|
6
|
+
* Configuration options for the {@link BullMQJobQueuePlugin}.
|
|
7
|
+
*
|
|
8
|
+
* @since 1.2.0
|
|
9
|
+
* @docsCategory core plugins/JobQueuePlugin
|
|
10
|
+
* @docsPage BullMQPluginOptions
|
|
11
|
+
* @docsWeight 0
|
|
12
|
+
*/
|
|
13
|
+
export interface BullMQPluginOptions {
|
|
14
|
+
/**
|
|
15
|
+
* @description
|
|
16
|
+
* Connection options which will be passed directly to BullMQ when
|
|
17
|
+
* creating a new Queue, Worker and Scheduler instance.
|
|
18
|
+
*
|
|
19
|
+
* If omitted, it will attempt to connect to Redis at `127.0.0.1:6379`.
|
|
20
|
+
*/
|
|
21
|
+
connection?: ConnectionOptions;
|
|
22
|
+
/**
|
|
23
|
+
* @description
|
|
24
|
+
* Additional options used when instantiating the BullMQ
|
|
25
|
+
* Queue instance.
|
|
26
|
+
* See the [BullMQ QueueOptions docs](https://github.com/taskforcesh/bullmq/blob/master/docs/gitbook/api/bullmq.queueoptions.md)
|
|
27
|
+
*/
|
|
28
|
+
queueOptions?: Omit<QueueOptions, "connection">;
|
|
29
|
+
/**
|
|
30
|
+
* @description
|
|
31
|
+
* Additional options used when instantiating the BullMQ
|
|
32
|
+
* Worker instance.
|
|
33
|
+
* See the [BullMQ WorkerOptions docs](https://github.com/taskforcesh/bullmq/blob/master/docs/gitbook/api/bullmq.workeroptions.md)
|
|
34
|
+
*/
|
|
35
|
+
workerOptions?: Omit<WorkerOptions, "connection">;
|
|
36
|
+
/**
|
|
37
|
+
* @description
|
|
38
|
+
* When a job is added to the JobQueue using `JobQueue.add()`, the calling
|
|
39
|
+
* code may specify the number of retries in case of failure. This option allows
|
|
40
|
+
* you to override that number and specify your own number of retries based on
|
|
41
|
+
* the job being added.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* setRetries: (queueName, job) => {
|
|
46
|
+
* if (queueName === 'send-email') {
|
|
47
|
+
* // Override the default number of retries
|
|
48
|
+
* // for the 'send-email' job because we have
|
|
49
|
+
* // a very unreliable email service.
|
|
50
|
+
* return 10;
|
|
51
|
+
* }
|
|
52
|
+
* return job.retries;
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @since 1.3.0
|
|
57
|
+
*/
|
|
58
|
+
setRetries?: (queueName: string, job: Job) => number;
|
|
59
|
+
/**
|
|
60
|
+
* @description
|
|
61
|
+
* This allows you to specify the backoff settings when a failed job gets retried.
|
|
62
|
+
* In other words, this determines how much time should pass before attempting to
|
|
63
|
+
* process the failed job again. If the function returns `undefined`, the default
|
|
64
|
+
* value of exponential/1000ms will be used.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* setBackoff: (queueName, job) => {
|
|
69
|
+
* return {
|
|
70
|
+
* type: 'exponential', // or 'fixed'
|
|
71
|
+
* delay: 10000 // first retry after 10s, second retry after 20s, 40s,...
|
|
72
|
+
* };
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
* @since 1.3.0
|
|
76
|
+
* @default 'exponential', 1000
|
|
77
|
+
*/
|
|
78
|
+
setBackoff?: (queueName: string, job: Job) => BackoffOptions | undefined;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* @description
|
|
82
|
+
* Configuration for the backoff function when retrying failed jobs.
|
|
83
|
+
*
|
|
84
|
+
* @since 1.3.0
|
|
85
|
+
* @docsCategory core plugins/JobQueuePlugin
|
|
86
|
+
* @docsPage BullMQPluginOptions
|
|
87
|
+
* @docsWeight 1
|
|
88
|
+
*/
|
|
89
|
+
export interface BackoffOptions {
|
|
90
|
+
type: "exponential" | "fixed";
|
|
91
|
+
delay: number;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* @description
|
|
95
|
+
* A definition for a Lua script used to define custom behavior in Redis
|
|
96
|
+
*/
|
|
97
|
+
export interface CustomScriptDefinition<T, Args extends any[]> {
|
|
98
|
+
name: string;
|
|
99
|
+
script: string;
|
|
100
|
+
numberOfKeys: number;
|
|
101
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/bullmq/types.ts"],"names":[],"mappings":""}
|
package/package/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.placeholder = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* This is a placeholder. Please import from one of the sub-packages, e.g `@deenruv/job-queue-plugin/package/bullmq`
|
|
6
|
+
*/
|
|
7
|
+
exports.placeholder = "Deenruv Job Queue Plugin";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,WAAW,GAAG,0BAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/pub-sub/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAC5C,QAAA,SAAS,GAAG,cAAc,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./plugin"), exports);
|
|
18
|
+
__exportStar(require("./options"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pub-sub/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface PubSubOptions {
|
|
2
|
+
/**
|
|
3
|
+
* @description
|
|
4
|
+
* Number of jobs that can be inflight at the same time.
|
|
5
|
+
*/
|
|
6
|
+
concurrency?: number;
|
|
7
|
+
/**
|
|
8
|
+
* @description
|
|
9
|
+
* This is the mapping of Deenruv queue names to PubSub Topics and Subscriptions
|
|
10
|
+
* For each queue a topic and subscription is required to exist.
|
|
11
|
+
*/
|
|
12
|
+
queueNamePubSubPair?: Map<string, [string, string]>;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/pub-sub/options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var PubSubPlugin_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.PubSubPlugin = void 0;
|
|
11
|
+
const pubsub_1 = require("@google-cloud/pubsub");
|
|
12
|
+
const core_1 = require("@deenruv/core");
|
|
13
|
+
const constants_1 = require("./constants");
|
|
14
|
+
const pub_sub_job_queue_strategy_1 = require("./pub-sub-job-queue-strategy");
|
|
15
|
+
let PubSubPlugin = PubSubPlugin_1 = class PubSubPlugin {
|
|
16
|
+
static init(options) {
|
|
17
|
+
this.options = options;
|
|
18
|
+
return PubSubPlugin_1;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
exports.PubSubPlugin = PubSubPlugin;
|
|
22
|
+
exports.PubSubPlugin = PubSubPlugin = PubSubPlugin_1 = __decorate([
|
|
23
|
+
(0, core_1.DeenruvPlugin)({
|
|
24
|
+
imports: [core_1.PluginCommonModule],
|
|
25
|
+
providers: [
|
|
26
|
+
{ provide: constants_1.PUB_SUB_OPTIONS, useFactory: () => PubSubPlugin.options },
|
|
27
|
+
{ provide: pubsub_1.PubSub, useFactory: () => new pubsub_1.PubSub() },
|
|
28
|
+
],
|
|
29
|
+
configuration: (config) => {
|
|
30
|
+
config.jobQueueOptions.jobQueueStrategy = new pub_sub_job_queue_strategy_1.PubSubJobQueueStrategy();
|
|
31
|
+
return config;
|
|
32
|
+
},
|
|
33
|
+
compatibility: "^0.0.0",
|
|
34
|
+
})
|
|
35
|
+
], PubSubPlugin);
|
|
36
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/pub-sub/plugin.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,iDAA8C;AAC9C,wCAAwE;AAExE,2CAA8C;AAE9C,6EAAsE;AAc/D,IAAM,YAAY,oBAAlB,MAAM,YAAY;IAGvB,MAAM,CAAC,IAAI,CAAC,OAAsB;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,OAAO,cAAY,CAAC;IACtB,CAAC;CACF,CAAA;AAPY,oCAAY;uBAAZ,YAAY;IAZxB,IAAA,oBAAa,EAAC;QACb,OAAO,EAAE,CAAC,yBAAkB,CAAC;QAC7B,SAAS,EAAE;YACT,EAAE,OAAO,EAAE,2BAAe,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE;YACpE,EAAE,OAAO,EAAE,eAAM,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,eAAM,EAAE,EAAE;SACpD;QACD,aAAa,EAAE,CAAC,MAAM,EAAE,EAAE;YACxB,MAAM,CAAC,eAAe,CAAC,gBAAgB,GAAG,IAAI,mDAAsB,EAAE,CAAC;YACvE,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,aAAa,EAAE,QAAQ;KACxB,CAAC;GACW,YAAY,CAOxB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { InjectableJobQueueStrategy, Injector, Job, JobData, JobQueueStrategy } from "@deenruv/core";
|
|
2
|
+
export declare class PubSubJobQueueStrategy extends InjectableJobQueueStrategy implements JobQueueStrategy {
|
|
3
|
+
private concurrency;
|
|
4
|
+
private queueNamePubSubPair;
|
|
5
|
+
private pubSubClient;
|
|
6
|
+
private topics;
|
|
7
|
+
private subscriptions;
|
|
8
|
+
private listeners;
|
|
9
|
+
init(injector: Injector): void;
|
|
10
|
+
destroy(): void;
|
|
11
|
+
add<Data extends JobData<Data> = object>(job: Job<Data>): Promise<Job<Data>>;
|
|
12
|
+
start<Data extends JobData<Data> = object>(queueName: string, process: (job: Job<Data>) => Promise<any>): Promise<void>;
|
|
13
|
+
stop<Data extends JobData<Data> = object>(queueName: string, process: (job: Job<Data>) => Promise<any>): Promise<void>;
|
|
14
|
+
private topic;
|
|
15
|
+
private subscription;
|
|
16
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PubSubJobQueueStrategy = void 0;
|
|
4
|
+
const pubsub_1 = require("@google-cloud/pubsub");
|
|
5
|
+
const generated_types_1 = require("@deenruv/common/lib/generated-types");
|
|
6
|
+
const core_1 = require("@deenruv/core");
|
|
7
|
+
const constants_1 = require("./constants");
|
|
8
|
+
class PubSubJobQueueStrategy extends core_1.InjectableJobQueueStrategy {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.topics = new Map();
|
|
12
|
+
this.subscriptions = new Map();
|
|
13
|
+
this.listeners = new core_1.QueueNameProcessStorage();
|
|
14
|
+
}
|
|
15
|
+
init(injector) {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
this.pubSubClient = injector.get(pubsub_1.PubSub);
|
|
18
|
+
const options = injector.get(constants_1.PUB_SUB_OPTIONS);
|
|
19
|
+
this.concurrency = (_a = options.concurrency) !== null && _a !== void 0 ? _a : 20;
|
|
20
|
+
this.queueNamePubSubPair = (_b = options.queueNamePubSubPair) !== null && _b !== void 0 ? _b : new Map();
|
|
21
|
+
super.init(injector);
|
|
22
|
+
}
|
|
23
|
+
destroy() {
|
|
24
|
+
super.destroy();
|
|
25
|
+
for (const subscription of this.subscriptions.values()) {
|
|
26
|
+
subscription.removeAllListeners("message");
|
|
27
|
+
}
|
|
28
|
+
this.subscriptions.clear();
|
|
29
|
+
this.topics.clear();
|
|
30
|
+
}
|
|
31
|
+
async add(job) {
|
|
32
|
+
if (!this.hasInitialized) {
|
|
33
|
+
throw new Error("Cannot add job before init");
|
|
34
|
+
}
|
|
35
|
+
const id = await this.topic(job.queueName).publish(Buffer.from(JSON.stringify(job.data)));
|
|
36
|
+
core_1.Logger.debug(`Sent message ${job.queueName}: ${id}`);
|
|
37
|
+
return new core_1.Job({
|
|
38
|
+
id,
|
|
39
|
+
queueName: job.queueName,
|
|
40
|
+
data: job.data,
|
|
41
|
+
attempts: 0,
|
|
42
|
+
state: generated_types_1.JobState.PENDING,
|
|
43
|
+
createdAt: new Date(),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
async start(queueName, process) {
|
|
47
|
+
if (!this.hasInitialized) {
|
|
48
|
+
this.started.set(queueName, process);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (this.listeners.has(queueName, process)) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const subscription = this.subscription(queueName);
|
|
55
|
+
const processMessage = async (message) => {
|
|
56
|
+
core_1.Logger.verbose(`Received message: ${queueName}: ${message.id}`, constants_1.loggerCtx);
|
|
57
|
+
const job = new core_1.Job({
|
|
58
|
+
id: message.id,
|
|
59
|
+
queueName,
|
|
60
|
+
data: JSON.parse(message.data.toString()),
|
|
61
|
+
attempts: message.deliveryAttempt,
|
|
62
|
+
state: generated_types_1.JobState.RUNNING,
|
|
63
|
+
startedAt: new Date(),
|
|
64
|
+
createdAt: message.publishTime,
|
|
65
|
+
});
|
|
66
|
+
await process(job);
|
|
67
|
+
};
|
|
68
|
+
const listener = (message) => {
|
|
69
|
+
processMessage(message)
|
|
70
|
+
.then(() => {
|
|
71
|
+
message.ack();
|
|
72
|
+
core_1.Logger.verbose(`Finished handling: ${queueName}: ${message.id}`, constants_1.loggerCtx);
|
|
73
|
+
})
|
|
74
|
+
.catch((err) => {
|
|
75
|
+
message.nack();
|
|
76
|
+
core_1.Logger.error(`Error handling: ${queueName}: ${message.id}: ${String(err.message)}`, constants_1.loggerCtx);
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
this.listeners.set(queueName, process, listener);
|
|
80
|
+
subscription.on("message", listener);
|
|
81
|
+
}
|
|
82
|
+
async stop(queueName, process) {
|
|
83
|
+
const listener = this.listeners.getAndDelete(queueName, process);
|
|
84
|
+
if (!listener) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
this.subscription(queueName).off("message", listener);
|
|
88
|
+
}
|
|
89
|
+
topic(queueName) {
|
|
90
|
+
let topic = this.topics.get(queueName);
|
|
91
|
+
if (topic) {
|
|
92
|
+
return topic;
|
|
93
|
+
}
|
|
94
|
+
const pair = this.queueNamePubSubPair.get(queueName);
|
|
95
|
+
if (!pair) {
|
|
96
|
+
throw new Error(`Topic name not set for queue: ${queueName}`);
|
|
97
|
+
}
|
|
98
|
+
const [topicName, subscriptionName] = pair;
|
|
99
|
+
topic = this.pubSubClient.topic(topicName);
|
|
100
|
+
this.topics.set(queueName, topic);
|
|
101
|
+
return topic;
|
|
102
|
+
}
|
|
103
|
+
subscription(queueName) {
|
|
104
|
+
let subscription = this.subscriptions.get(queueName);
|
|
105
|
+
if (subscription) {
|
|
106
|
+
return subscription;
|
|
107
|
+
}
|
|
108
|
+
const pair = this.queueNamePubSubPair.get(queueName);
|
|
109
|
+
if (!pair) {
|
|
110
|
+
throw new Error(`Subscription name not set for queue: ${queueName}`);
|
|
111
|
+
}
|
|
112
|
+
const [topicName, subscriptionName] = pair;
|
|
113
|
+
subscription = this.topic(queueName).subscription(subscriptionName, {
|
|
114
|
+
flowControl: {
|
|
115
|
+
maxMessages: this.concurrency,
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
this.subscriptions.set(queueName, subscription);
|
|
119
|
+
return subscription;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.PubSubJobQueueStrategy = PubSubJobQueueStrategy;
|
|
123
|
+
//# sourceMappingURL=pub-sub-job-queue-strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pub-sub-job-queue-strategy.js","sourceRoot":"","sources":["../../src/pub-sub/pub-sub-job-queue-strategy.ts"],"names":[],"mappings":";;;AAAA,iDAA4E;AAC5E,yEAA+D;AAC/D,wCAQuB;AAEvB,2CAAyD;AAGzD,MAAa,sBACX,SAAQ,iCAA0B;IADpC;;QAOU,WAAM,GAAG,IAAI,GAAG,EAAiB,CAAC;QAClC,kBAAa,GAAG,IAAI,GAAG,EAAwB,CAAC;QAChD,cAAS,GAAG,IAAI,8BAAuB,EAA8B,CAAC;IAmJhF,CAAC;IAjJC,IAAI,CAAC,QAAkB;;QACrB,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,eAAM,CAAC,CAAC;QACzC,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAgB,2BAAe,CAAC,CAAC;QAC7D,IAAI,CAAC,WAAW,GAAG,MAAA,OAAO,CAAC,WAAW,mCAAI,EAAE,CAAC;QAC7C,IAAI,CAAC,mBAAmB,GAAG,MAAA,OAAO,CAAC,mBAAmB,mCAAI,IAAI,GAAG,EAAE,CAAC;QAEpE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvB,CAAC;IAED,OAAO;QACL,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,KAAK,MAAM,YAAY,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,EAAE,CAAC;YACvD,YAAY,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;QAC7C,CAAC;QACD,IAAI,CAAC,aAAa,CAAC,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,KAAK,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC,gBAAgB,EAAE;YAClE,WAAW,EAAE;gBACX,WAAW,EAAE,IAAI,CAAC,WAAW;aAC9B;SACF,CAAC,CAAC;QACH,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QAEhD,OAAO,YAAY,CAAC;IACtB,CAAC;CACF;AA5JD,wDA4JC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@deenruv/job-queue-plugin",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"main": "package/index.js",
|
|
6
|
+
"types": "package/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"package/**/*"
|
|
9
|
+
],
|
|
10
|
+
"private": false,
|
|
11
|
+
"homepage": "https://deenruv.com/",
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"@deenruv/core": "^0.1.0",
|
|
17
|
+
"rxjs": "7.8.1"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@google-cloud/pubsub": "^2.8.0",
|
|
21
|
+
"bullmq": "^5.4.2",
|
|
22
|
+
"ioredis": "^5.3.2",
|
|
23
|
+
"rimraf": "^5.0.5",
|
|
24
|
+
"rxjs": "7.8.1",
|
|
25
|
+
"typescript": "5.3.3",
|
|
26
|
+
"@deenruv/core": "^1.0.0",
|
|
27
|
+
"@deenruv/common": "^1.0.0"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@nestjs/common": "^10.3.10",
|
|
31
|
+
"@nestjs/terminus": "^10.2.3"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"watch": "tsc -p ./tsconfig.build.json --watch",
|
|
35
|
+
"build": "rimraf package && tsc -p ./tsconfig.build.json",
|
|
36
|
+
"lint": "eslint .",
|
|
37
|
+
"lint:fix": "eslint --fix .",
|
|
38
|
+
"test": "vitest --run",
|
|
39
|
+
"e2e-wip": "node e2e/check-connection.js || jest --config ../../e2e-common/jest-config.js --runInBand --package=job-queue-plugin",
|
|
40
|
+
"ci": "npm run build"
|
|
41
|
+
}
|
|
42
|
+
}
|