@spinajs/queue 2.0.179 → 2.0.181
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/lib/cjs/BlackHoleQueueClient.d.ts +11 -11
- package/lib/cjs/BlackHoleQueueClient.js +29 -29
- package/lib/cjs/BlackHoleQueueClient.js.map +1 -1
- package/lib/cjs/config/queue.d.ts +10 -10
- package/lib/cjs/config/queue.js +17 -17
- package/lib/cjs/decorators.d.ts +19 -19
- package/lib/cjs/decorators.js +35 -35
- package/lib/cjs/index.d.ts +38 -38
- package/lib/cjs/index.js +167 -167
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interfaces.d.ts +213 -213
- package/lib/cjs/interfaces.js +168 -168
- package/lib/cjs/interfaces.js.map +1 -1
- package/lib/cjs/migrations/Queue_2022_10_18_01_13_00.d.ts +5 -5
- package/lib/cjs/migrations/Queue_2022_10_18_01_13_00.js +35 -35
- package/lib/cjs/migrations/Queue_2022_10_18_01_13_00.js.map +1 -1
- package/lib/cjs/models/JobModel.d.ts +19 -19
- package/lib/cjs/models/JobModel.js +46 -46
- package/lib/cjs/models/JobModel.js.map +1 -1
- package/lib/mjs/BlackHoleQueueClient.d.ts +11 -11
- package/lib/mjs/BlackHoleQueueClient.js +26 -26
- package/lib/mjs/BlackHoleQueueClient.js.map +1 -1
- package/lib/mjs/config/queue.d.ts +10 -10
- package/lib/mjs/config/queue.js +15 -15
- package/lib/mjs/decorators.d.ts +19 -19
- package/lib/mjs/decorators.js +30 -30
- package/lib/mjs/index.d.ts +38 -38
- package/lib/mjs/index.js +150 -150
- package/lib/mjs/index.js.map +1 -1
- package/lib/mjs/interfaces.d.ts +213 -213
- package/lib/mjs/interfaces.js +156 -156
- package/lib/mjs/interfaces.js.map +1 -1
- package/lib/mjs/migrations/Queue_2022_10_18_01_13_00.d.ts +5 -5
- package/lib/mjs/migrations/Queue_2022_10_18_01_13_00.js +32 -32
- package/lib/mjs/migrations/Queue_2022_10_18_01_13_00.js.map +1 -1
- package/lib/mjs/models/JobModel.d.ts +19 -19
- package/lib/mjs/models/JobModel.js +43 -43
- package/lib/mjs/models/JobModel.js.map +1 -1
- package/lib/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/tsconfig.mjs.tsbuildinfo +1 -1
- package/package.json +6 -6
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Constructor } from '@spinajs/di';
|
|
2
|
-
import { IQueueMessage, QueueClient, QueueMessage } from './interfaces.js';
|
|
3
|
-
/**
|
|
4
|
-
* Empty queue, does nothing.
|
|
5
|
-
* Use it, if you want to route or dismiss messages sent by queue service
|
|
6
|
-
*/
|
|
7
|
-
export declare class BlackHoleQueueClient extends QueueClient {
|
|
8
|
-
emit(_event: IQueueMessage): Promise<void>;
|
|
9
|
-
subscribe(_channel: string | Constructor<QueueMessage>, _callback: (e: IQueueMessage) => Promise<void>, _subscriptionId?: string, _durable?: boolean): Promise<void>;
|
|
10
|
-
unsubscribe(_channel: string | Constructor<QueueMessage>): void;
|
|
11
|
-
}
|
|
1
|
+
import { Constructor } from '@spinajs/di';
|
|
2
|
+
import { IQueueMessage, QueueClient, QueueMessage } from './interfaces.js';
|
|
3
|
+
/**
|
|
4
|
+
* Empty queue, does nothing.
|
|
5
|
+
* Use it, if you want to route or dismiss messages sent by queue service
|
|
6
|
+
*/
|
|
7
|
+
export declare class BlackHoleQueueClient extends QueueClient {
|
|
8
|
+
emit(_event: IQueueMessage): Promise<void>;
|
|
9
|
+
subscribe(_channel: string | Constructor<QueueMessage>, _callback: (e: IQueueMessage) => Promise<void>, _subscriptionId?: string, _durable?: boolean): Promise<void>;
|
|
10
|
+
unsubscribe(_channel: string | Constructor<QueueMessage>): void;
|
|
11
|
+
}
|
|
12
12
|
//# sourceMappingURL=BlackHoleQueueClient.d.ts.map
|
|
@@ -1,30 +1,30 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.BlackHoleQueueClient = void 0;
|
|
10
|
-
const di_1 = require("@spinajs/di");
|
|
11
|
-
const interfaces_js_1 = require("./interfaces.js");
|
|
12
|
-
/**
|
|
13
|
-
* Empty queue, does nothing.
|
|
14
|
-
* Use it, if you want to route or dismiss messages sent by queue service
|
|
15
|
-
*/
|
|
16
|
-
let BlackHoleQueueClient = class BlackHoleQueueClient extends interfaces_js_1.QueueClient {
|
|
17
|
-
emit(_event) {
|
|
18
|
-
return Promise.resolve();
|
|
19
|
-
}
|
|
20
|
-
subscribe(_channel, _callback, _subscriptionId, _durable) {
|
|
21
|
-
return Promise.resolve();
|
|
22
|
-
}
|
|
23
|
-
unsubscribe(_channel) { }
|
|
24
|
-
};
|
|
25
|
-
BlackHoleQueueClient =
|
|
26
|
-
|
|
27
|
-
(0, di_1.
|
|
28
|
-
|
|
29
|
-
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.BlackHoleQueueClient = void 0;
|
|
10
|
+
const di_1 = require("@spinajs/di");
|
|
11
|
+
const interfaces_js_1 = require("./interfaces.js");
|
|
12
|
+
/**
|
|
13
|
+
* Empty queue, does nothing.
|
|
14
|
+
* Use it, if you want to route or dismiss messages sent by queue service
|
|
15
|
+
*/
|
|
16
|
+
let BlackHoleQueueClient = class BlackHoleQueueClient extends interfaces_js_1.QueueClient {
|
|
17
|
+
emit(_event) {
|
|
18
|
+
return Promise.resolve();
|
|
19
|
+
}
|
|
20
|
+
subscribe(_channel, _callback, _subscriptionId, _durable) {
|
|
21
|
+
return Promise.resolve();
|
|
22
|
+
}
|
|
23
|
+
unsubscribe(_channel) { }
|
|
24
|
+
};
|
|
25
|
+
exports.BlackHoleQueueClient = BlackHoleQueueClient;
|
|
26
|
+
exports.BlackHoleQueueClient = BlackHoleQueueClient = __decorate([
|
|
27
|
+
(0, di_1.NewInstance)(),
|
|
28
|
+
(0, di_1.Injectable)(interfaces_js_1.QueueClient)
|
|
29
|
+
], BlackHoleQueueClient);
|
|
30
30
|
//# sourceMappingURL=BlackHoleQueueClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlackHoleQueueClient.js","sourceRoot":"","sources":["../../src/BlackHoleQueueClient.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oCAAmE;AACnE,mDAA2E;AAE3E;;;GAGG;AAGI,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,2BAAW;IAC5C,IAAI,CAAC,MAAqB;QAC/B,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IACM,SAAS,CAAC,QAA4C,EAAE,SAA8C,EAAE,eAAwB,EAAE,QAAkB;QACzJ,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IACM,WAAW,CAAC,QAA4C,IAAS,CAAC;CAC1E,CAAA;AARY,oBAAoB;IAFhC,IAAA,gBAAW,GAAE;IACb,IAAA,eAAU,EAAC,2BAAW,CAAC;GACX,oBAAoB,CAQhC
|
|
1
|
+
{"version":3,"file":"BlackHoleQueueClient.js","sourceRoot":"","sources":["../../src/BlackHoleQueueClient.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oCAAmE;AACnE,mDAA2E;AAE3E;;;GAGG;AAGI,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,2BAAW;IAC5C,IAAI,CAAC,MAAqB;QAC/B,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IACM,SAAS,CAAC,QAA4C,EAAE,SAA8C,EAAE,eAAwB,EAAE,QAAkB;QACzJ,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IACM,WAAW,CAAC,QAA4C,IAAS,CAAC;CAC1E,CAAA;AARY,oDAAoB;+BAApB,oBAAoB;IAFhC,IAAA,gBAAW,GAAE;IACb,IAAA,eAAU,EAAC,2BAAW,CAAC;GACX,oBAAoB,CAQhC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
declare const queue: {
|
|
2
|
-
queue: {
|
|
3
|
-
default: string;
|
|
4
|
-
connections: {
|
|
5
|
-
name: string;
|
|
6
|
-
service: string;
|
|
7
|
-
}[];
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
export default queue;
|
|
1
|
+
declare const queue: {
|
|
2
|
+
queue: {
|
|
3
|
+
default: string;
|
|
4
|
+
connections: {
|
|
5
|
+
name: string;
|
|
6
|
+
service: string;
|
|
7
|
+
}[];
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export default queue;
|
|
11
11
|
//# sourceMappingURL=queue.d.ts.map
|
package/lib/cjs/config/queue.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const queue = {
|
|
4
|
-
queue: {
|
|
5
|
-
// by default, all messages are sent to black hole
|
|
6
|
-
// becouse some modules use queues to pass events eg. user login
|
|
7
|
-
// but not always in project we want to use queue or have queue server
|
|
8
|
-
default: 'black-hole',
|
|
9
|
-
connections: [
|
|
10
|
-
{
|
|
11
|
-
name: 'black-hole',
|
|
12
|
-
service: 'BlackHoleQueueClient',
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
exports.default = queue;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const queue = {
|
|
4
|
+
queue: {
|
|
5
|
+
// by default, all messages are sent to black hole
|
|
6
|
+
// becouse some modules use queues to pass events eg. user login
|
|
7
|
+
// but not always in project we want to use queue or have queue server
|
|
8
|
+
default: 'black-hole',
|
|
9
|
+
connections: [
|
|
10
|
+
{
|
|
11
|
+
name: 'black-hole',
|
|
12
|
+
service: 'BlackHoleQueueClient',
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
exports.default = queue;
|
|
18
18
|
//# sourceMappingURL=queue.js.map
|
package/lib/cjs/decorators.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export interface IEventOption {
|
|
2
|
-
/**
|
|
3
|
-
* Should event survive consumer restart ?
|
|
4
|
-
*/
|
|
5
|
-
durable?: boolean;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* Mark class as job
|
|
10
|
-
*
|
|
11
|
-
* @param connection - job connection name for use, if not set default connection is used
|
|
12
|
-
*/
|
|
13
|
-
export declare function Job(): (target: any) => void;
|
|
14
|
-
/**
|
|
15
|
-
* Mark class as event
|
|
16
|
-
*
|
|
17
|
-
* @param connection - event connection name for use, if not set default connection is used
|
|
18
|
-
*/
|
|
19
|
-
export declare function Event(options?: IEventOption): (target: any) => void;
|
|
1
|
+
export interface IEventOption {
|
|
2
|
+
/**
|
|
3
|
+
* Should event survive consumer restart ?
|
|
4
|
+
*/
|
|
5
|
+
durable?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* Mark class as job
|
|
10
|
+
*
|
|
11
|
+
* @param connection - job connection name for use, if not set default connection is used
|
|
12
|
+
*/
|
|
13
|
+
export declare function Job(): (target: any) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Mark class as event
|
|
16
|
+
*
|
|
17
|
+
* @param connection - event connection name for use, if not set default connection is used
|
|
18
|
+
*/
|
|
19
|
+
export declare function Event(options?: IEventOption): (target: any) => void;
|
|
20
20
|
//# sourceMappingURL=decorators.d.ts.map
|
package/lib/cjs/decorators.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Event = exports.Job = void 0;
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* Mark class as job
|
|
7
|
-
*
|
|
8
|
-
* @param connection - job connection name for use, if not set default connection is used
|
|
9
|
-
*/
|
|
10
|
-
function Job() {
|
|
11
|
-
return (target) => {
|
|
12
|
-
if (!Reflect.hasMetadata('queue:options', target)) {
|
|
13
|
-
Reflect.defineMetadata('queue:options', {
|
|
14
|
-
type: 'job',
|
|
15
|
-
}, target);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
exports.Job = Job;
|
|
20
|
-
/**
|
|
21
|
-
* Mark class as event
|
|
22
|
-
*
|
|
23
|
-
* @param connection - event connection name for use, if not set default connection is used
|
|
24
|
-
*/
|
|
25
|
-
function Event(options) {
|
|
26
|
-
return (target) => {
|
|
27
|
-
if (!Reflect.hasMetadata('queue:options', target)) {
|
|
28
|
-
Reflect.defineMetadata('queue:options', {
|
|
29
|
-
...options,
|
|
30
|
-
type: 'event',
|
|
31
|
-
}, target);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
exports.Event = Event;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Event = exports.Job = void 0;
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* Mark class as job
|
|
7
|
+
*
|
|
8
|
+
* @param connection - job connection name for use, if not set default connection is used
|
|
9
|
+
*/
|
|
10
|
+
function Job() {
|
|
11
|
+
return (target) => {
|
|
12
|
+
if (!Reflect.hasMetadata('queue:options', target)) {
|
|
13
|
+
Reflect.defineMetadata('queue:options', {
|
|
14
|
+
type: 'job',
|
|
15
|
+
}, target);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.Job = Job;
|
|
20
|
+
/**
|
|
21
|
+
* Mark class as event
|
|
22
|
+
*
|
|
23
|
+
* @param connection - event connection name for use, if not set default connection is used
|
|
24
|
+
*/
|
|
25
|
+
function Event(options) {
|
|
26
|
+
return (target) => {
|
|
27
|
+
if (!Reflect.hasMetadata('queue:options', target)) {
|
|
28
|
+
Reflect.defineMetadata('queue:options', {
|
|
29
|
+
...options,
|
|
30
|
+
type: 'event',
|
|
31
|
+
}, target);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
exports.Event = Event;
|
|
36
36
|
//# sourceMappingURL=decorators.js.map
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { Constructor } from '@spinajs/di';
|
|
2
|
-
import { Log } from '@spinajs/log';
|
|
3
|
-
import { QueueClient, QueueJob, QueueEvent, IQueueMessage, QueueMessage, QueueService } from './interfaces.js';
|
|
4
|
-
export * from './BlackHoleQueueClient.js';
|
|
5
|
-
export * from './interfaces.js';
|
|
6
|
-
export * from './decorators.js';
|
|
7
|
-
export * from './models/JobModel.js';
|
|
8
|
-
export * from './migrations/Queue_2022_10_18_01_13_00.js';
|
|
9
|
-
export declare class DefaultQueueService extends QueueService {
|
|
10
|
-
protected Log: Log;
|
|
11
|
-
protected Connections: Map<string, QueueClient>;
|
|
12
|
-
dispose(): Promise<void>;
|
|
13
|
-
emit(event: IQueueMessage | QueueEvent | QueueJob): Promise<void>;
|
|
14
|
-
stopConsuming(event: Constructor<QueueMessage>): Promise<void>;
|
|
15
|
-
/**
|
|
16
|
-
*
|
|
17
|
-
* Starts to consume events/jobs from connection
|
|
18
|
-
*
|
|
19
|
-
* NOTE: When consuming events, we can have multiple event types on same channel, couse
|
|
20
|
-
* subscribe function filters it out, and event can be handled in another subscription
|
|
21
|
-
*
|
|
22
|
-
* When consuming jobs, multiple jobs on same channel can have unpredictible behavior becouse
|
|
23
|
-
* job can be executed once even with multiple subscribers, so filtering it out
|
|
24
|
-
* prevents from executing it on other subscriptions
|
|
25
|
-
*
|
|
26
|
-
* @param event - event type to consume
|
|
27
|
-
* @param callback - optional callback when job is consumet, mandatory for events
|
|
28
|
-
* @param subscriptionId - optional subscription id if consuming durable events
|
|
29
|
-
* @param durable - is durable event, if not set, this value default to event decorator options
|
|
30
|
-
*/
|
|
31
|
-
consume<T extends QueueMessage>(event: Constructor<QueueMessage>, callback?: (message: T) => Promise<void>, subscriptionId?: string, durable?: boolean): Promise<void>;
|
|
32
|
-
/**
|
|
33
|
-
* Get specific queue client connection. If no connection param is provided, default is returned.
|
|
34
|
-
* @param connection - connection name to obtain
|
|
35
|
-
* @returns
|
|
36
|
-
*/
|
|
37
|
-
get(connection?: string): QueueClient;
|
|
38
|
-
}
|
|
1
|
+
import { Constructor } from '@spinajs/di';
|
|
2
|
+
import { Log } from '@spinajs/log';
|
|
3
|
+
import { QueueClient, QueueJob, QueueEvent, IQueueMessage, QueueMessage, QueueService } from './interfaces.js';
|
|
4
|
+
export * from './BlackHoleQueueClient.js';
|
|
5
|
+
export * from './interfaces.js';
|
|
6
|
+
export * from './decorators.js';
|
|
7
|
+
export * from './models/JobModel.js';
|
|
8
|
+
export * from './migrations/Queue_2022_10_18_01_13_00.js';
|
|
9
|
+
export declare class DefaultQueueService extends QueueService {
|
|
10
|
+
protected Log: Log;
|
|
11
|
+
protected Connections: Map<string, QueueClient>;
|
|
12
|
+
dispose(): Promise<void>;
|
|
13
|
+
emit(event: IQueueMessage | QueueEvent | QueueJob): Promise<void>;
|
|
14
|
+
stopConsuming(event: Constructor<QueueMessage>): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* Starts to consume events/jobs from connection
|
|
18
|
+
*
|
|
19
|
+
* NOTE: When consuming events, we can have multiple event types on same channel, couse
|
|
20
|
+
* subscribe function filters it out, and event can be handled in another subscription
|
|
21
|
+
*
|
|
22
|
+
* When consuming jobs, multiple jobs on same channel can have unpredictible behavior becouse
|
|
23
|
+
* job can be executed once even with multiple subscribers, so filtering it out
|
|
24
|
+
* prevents from executing it on other subscriptions
|
|
25
|
+
*
|
|
26
|
+
* @param event - event type to consume
|
|
27
|
+
* @param callback - optional callback when job is consumet, mandatory for events
|
|
28
|
+
* @param subscriptionId - optional subscription id if consuming durable events
|
|
29
|
+
* @param durable - is durable event, if not set, this value default to event decorator options
|
|
30
|
+
*/
|
|
31
|
+
consume<T extends QueueMessage>(event: Constructor<QueueMessage>, callback?: (message: T) => Promise<void>, subscriptionId?: string, durable?: boolean): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Get specific queue client connection. If no connection param is provided, default is returned.
|
|
34
|
+
* @param connection - connection name to obtain
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
get(connection?: string): QueueClient;
|
|
38
|
+
}
|
|
39
39
|
//# sourceMappingURL=index.d.ts.map
|