@spinajs/queue 2.0.45 → 2.0.50
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 +11 -11
- package/lib/BlackHoleQueueClient.d.ts +2 -1
- package/lib/BlackHoleQueueClient.d.ts.map +1 -0
- package/lib/BlackHoleQueueClient.js +6 -9
- package/lib/BlackHoleQueueClient.js.map +1 -1
- package/lib/config/queue.d.ts +2 -0
- package/lib/config/queue.d.ts.map +1 -0
- package/lib/config/queue.js +1 -0
- package/lib/decorators.d.ts +1 -0
- package/lib/decorators.d.ts.map +1 -0
- package/lib/decorators.js +6 -8
- package/lib/decorators.js.map +1 -1
- package/lib/index.d.ts +7 -6
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +34 -52
- package/lib/index.js.map +1 -1
- package/lib/interfaces.d.ts +1 -0
- package/lib/interfaces.d.ts.map +1 -0
- package/lib/interfaces.js +50 -55
- package/lib/interfaces.js.map +1 -1
- package/lib/migrations/Queue_2022_10_18_01_13_00.d.ts +1 -0
- package/lib/migrations/Queue_2022_10_18_01_13_00.d.ts.map +1 -0
- package/lib/migrations/Queue_2022_10_18_01_13_00.js +4 -7
- package/lib/migrations/Queue_2022_10_18_01_13_00.js.map +1 -1
- package/lib/models/JobModel.d.ts +1 -0
- package/lib/models/JobModel.d.ts.map +1 -0
- package/lib/models/JobModel.js +14 -17
- package/lib/models/JobModel.js.map +1 -1
- package/package.json +56 -53
- package/lib/bootstrap.d.ts +0 -4
- package/lib/bootstrap.js +0 -25
- package/lib/bootstrap.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# `jobs`
|
|
2
|
-
|
|
3
|
-
> TODO: description
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
const jobs = require('jobs');
|
|
9
|
-
|
|
10
|
-
// TODO: DEMONSTRATE API
|
|
11
|
-
```
|
|
1
|
+
# `jobs`
|
|
2
|
+
|
|
3
|
+
> TODO: description
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
const jobs = require('jobs');
|
|
9
|
+
|
|
10
|
+
// TODO: DEMONSTRATE API
|
|
11
|
+
```
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Constructor } from '@spinajs/di';
|
|
2
|
-
import { IQueueMessage, QueueClient, QueueMessage } from './interfaces';
|
|
2
|
+
import { IQueueMessage, QueueClient, QueueMessage } from './interfaces.js';
|
|
3
3
|
/**
|
|
4
4
|
* Empty queue, does nothing.
|
|
5
5
|
* Use it, if you want to route or dismiss messages sent by queue service
|
|
@@ -9,3 +9,4 @@ export declare class BlackHoleQueueClient extends QueueClient {
|
|
|
9
9
|
subscribe(_channel: string | Constructor<QueueMessage>, _callback: (e: IQueueMessage) => Promise<void>, _subscriptionId?: string, _durable?: boolean): Promise<void>;
|
|
10
10
|
unsubscribe(_channel: string | Constructor<QueueMessage>): void;
|
|
11
11
|
}
|
|
12
|
+
//# sourceMappingURL=BlackHoleQueueClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlackHoleQueueClient.d.ts","sourceRoot":"","sources":["../src/BlackHoleQueueClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA2B,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE3E;;;GAGG;AACH,qBAEa,oBAAqB,SAAQ,WAAW;IAC5C,IAAI,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAG1C,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,CAAC,YAAY,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,EAAE,eAAe,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAGpK,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,CAAC,YAAY,CAAC,GAAG,IAAI;CACvE"}
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
4
|
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
6
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const di_1 = require("@spinajs/di");
|
|
11
|
-
const interfaces_1 = require("./interfaces");
|
|
7
|
+
import { Injectable, NewInstance } from '@spinajs/di';
|
|
8
|
+
import { QueueClient } from './interfaces.js';
|
|
12
9
|
/**
|
|
13
10
|
* Empty queue, does nothing.
|
|
14
11
|
* Use it, if you want to route or dismiss messages sent by queue service
|
|
15
12
|
*/
|
|
16
|
-
let BlackHoleQueueClient = class BlackHoleQueueClient extends
|
|
13
|
+
let BlackHoleQueueClient = class BlackHoleQueueClient extends QueueClient {
|
|
17
14
|
emit(_event) {
|
|
18
15
|
return Promise.resolve();
|
|
19
16
|
}
|
|
@@ -23,8 +20,8 @@ let BlackHoleQueueClient = class BlackHoleQueueClient extends interfaces_1.Queue
|
|
|
23
20
|
unsubscribe(_channel) { }
|
|
24
21
|
};
|
|
25
22
|
BlackHoleQueueClient = __decorate([
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
NewInstance(),
|
|
24
|
+
Injectable(QueueClient)
|
|
28
25
|
], BlackHoleQueueClient);
|
|
29
|
-
|
|
26
|
+
export { BlackHoleQueueClient };
|
|
30
27
|
//# sourceMappingURL=BlackHoleQueueClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlackHoleQueueClient.js","sourceRoot":"","sources":["../src/BlackHoleQueueClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BlackHoleQueueClient.js","sourceRoot":"","sources":["../src/BlackHoleQueueClient.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAe,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAiB,WAAW,EAAgB,MAAM,iBAAiB,CAAC;AAE3E;;;GAGG;AAGI,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,WAAW;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,WAAW,EAAE;IACb,UAAU,CAAC,WAAW,CAAC;GACX,oBAAoB,CAQhC;SARY,oBAAoB"}
|
package/lib/config/queue.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/config/queue.ts"],"names":[],"mappings":""}
|
package/lib/config/queue.js
CHANGED
package/lib/decorators.d.ts
CHANGED
|
@@ -14,3 +14,4 @@ export declare function Job(): (target: any) => void;
|
|
|
14
14
|
* @param connection - event connection name for use, if not set default connection is used
|
|
15
15
|
*/
|
|
16
16
|
export declare function Event(options?: IEventOption): (target: any) => void;
|
|
17
|
+
//# sourceMappingURL=decorators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,aACD,GAAG,UAWpB;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,YAC1B,GAAG,UAYpB"}
|
package/lib/decorators.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Event = exports.Job = void 0;
|
|
4
1
|
/**
|
|
5
2
|
*
|
|
6
3
|
* Mark class as job
|
|
7
4
|
*
|
|
8
5
|
* @param connection - job connection name for use, if not set default connection is used
|
|
9
6
|
*/
|
|
10
|
-
function Job() {
|
|
7
|
+
export function Job() {
|
|
11
8
|
return (target) => {
|
|
12
9
|
if (!Reflect.hasMetadata('queue:options', target)) {
|
|
13
10
|
Reflect.defineMetadata('queue:options', {
|
|
@@ -16,18 +13,19 @@ function Job() {
|
|
|
16
13
|
}
|
|
17
14
|
};
|
|
18
15
|
}
|
|
19
|
-
exports.Job = Job;
|
|
20
16
|
/**
|
|
21
17
|
* Mark class as event
|
|
22
18
|
*
|
|
23
19
|
* @param connection - event connection name for use, if not set default connection is used
|
|
24
20
|
*/
|
|
25
|
-
function Event(options) {
|
|
21
|
+
export function Event(options) {
|
|
26
22
|
return (target) => {
|
|
27
23
|
if (!Reflect.hasMetadata('queue:options', target)) {
|
|
28
|
-
Reflect.defineMetadata('queue:options',
|
|
24
|
+
Reflect.defineMetadata('queue:options', {
|
|
25
|
+
...options,
|
|
26
|
+
type: 'event',
|
|
27
|
+
}, target);
|
|
29
28
|
}
|
|
30
29
|
};
|
|
31
30
|
}
|
|
32
|
-
exports.Event = Event;
|
|
33
31
|
//# sourceMappingURL=decorators.js.map
|
package/lib/decorators.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,UAAU,GAAG;IACjB,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,eAAe,EAAE,MAAM,CAAC,EAAE;YACjD,OAAO,CAAC,cAAc,CACpB,eAAe,EACf;gBACE,IAAI,EAAE,KAAK;aACZ,EACD,MAAM,CACP,CAAC;SACH;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,OAAsB;IAC1C,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,eAAe,EAAE,MAAM,CAAC,EAAE;YACjD,OAAO,CAAC,cAAc,CACpB,eAAe,EACf;gBACE,GAAG,OAAO;gBACV,IAAI,EAAE,OAAO;aACd,EACD,MAAM,CACP,CAAC;SACH;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Constructor } from '@spinajs/di';
|
|
2
2
|
import { Log } from '@spinajs/log';
|
|
3
|
-
import { QueueClient, QueueJob, QueueEvent, IQueueMessage, QueueMessage, QueueService } from './interfaces';
|
|
4
|
-
export * from './BlackHoleQueueClient';
|
|
5
|
-
export * from './interfaces';
|
|
6
|
-
export * from './decorators';
|
|
7
|
-
export * from './models/JobModel';
|
|
8
|
-
export * from './migrations/Queue_2022_10_18_01_13_00';
|
|
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
9
|
export declare class DefaultQueueService extends QueueService {
|
|
10
10
|
protected Log: Log;
|
|
11
11
|
protected Connections: Map<string, QueueClient>;
|
|
@@ -36,3 +36,4 @@ export declare class DefaultQueueService extends QueueService {
|
|
|
36
36
|
*/
|
|
37
37
|
get(connection?: string): QueueClient;
|
|
38
38
|
}
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAmC,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,GAAG,EAAU,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAS,MAAM,iBAAiB,CAAC;AAMtH,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2CAA2C,CAAC;AAE1D,qBACa,mBAAoB,SAAQ,YAAY;IAEnD,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC;IAGnB,SAAS,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAEnC,OAAO;IAQP,IAAI,CAAC,KAAK,EAAE,aAAa,GAAG,UAAU,GAAG,QAAQ;IAuBjD,aAAa,CAAC,KAAK,EAAE,WAAW,CAAC,YAAY,CAAC;IAI3D;;;;;;;;;;;;;;;OAeG;IACU,OAAO,CAAC,CAAC,SAAS,YAAY,EAAE,KAAK,EAAE,WAAW,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,EAAE,cAAc,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO;IAuFnK;;;;OAIG;IACI,GAAG,CAAC,UAAU,CAAC,EAAE,MAAM;CAG/B"}
|
package/lib/index.js
CHANGED
|
@@ -1,43 +1,26 @@
|
|
|
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
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
14
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
15
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
16
4
|
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;
|
|
17
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18
6
|
};
|
|
19
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
-
};
|
|
22
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
23
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
24
9
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
__exportStar(require("./migrations/Queue_2022_10_18_01_13_00"), exports);
|
|
40
|
-
let DefaultQueueService = class DefaultQueueService extends interfaces_1.QueueService {
|
|
10
|
+
import { UnexpectedServerError, InvalidArgument } from '@spinajs/exceptions';
|
|
11
|
+
import { DI, Injectable, ServiceNotFound } from '@spinajs/di';
|
|
12
|
+
import { Log, Logger } from '@spinajs/log';
|
|
13
|
+
import { QueueClient, QueueJob, QueueEvent, QueueService, isJob } from './interfaces.js';
|
|
14
|
+
import { JobModel } from './models/JobModel.js';
|
|
15
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
16
|
+
import { AutoinjectService } from '@spinajs/configuration';
|
|
17
|
+
import { DateTime } from 'luxon';
|
|
18
|
+
export * from './BlackHoleQueueClient.js';
|
|
19
|
+
export * from './interfaces.js';
|
|
20
|
+
export * from './decorators.js';
|
|
21
|
+
export * from './models/JobModel.js';
|
|
22
|
+
export * from './migrations/Queue_2022_10_18_01_13_00.js';
|
|
23
|
+
let DefaultQueueService = class DefaultQueueService extends QueueService {
|
|
41
24
|
async dispose() {
|
|
42
25
|
this.Connections.forEach(async (val) => {
|
|
43
26
|
await val.dispose();
|
|
@@ -47,9 +30,9 @@ let DefaultQueueService = class DefaultQueueService extends interfaces_1.QueueSe
|
|
|
47
30
|
async emit(event) {
|
|
48
31
|
const connections = this.getConnectionsForMessage(event);
|
|
49
32
|
for (let c of connections) {
|
|
50
|
-
if (
|
|
51
|
-
const jModel = new
|
|
52
|
-
jModel.JobId = (
|
|
33
|
+
if (isJob(event)) {
|
|
34
|
+
const jModel = new JobModel();
|
|
35
|
+
jModel.JobId = uuidv4();
|
|
53
36
|
jModel.Name = event.Name;
|
|
54
37
|
jModel.Status = 'created';
|
|
55
38
|
jModel.Progress = 0;
|
|
@@ -81,42 +64,41 @@ let DefaultQueueService = class DefaultQueueService extends interfaces_1.QueueSe
|
|
|
81
64
|
* @param durable - is durable event, if not set, this value default to event decorator options
|
|
82
65
|
*/
|
|
83
66
|
async consume(event, callback, subscriptionId, durable) {
|
|
84
|
-
var _a;
|
|
85
67
|
const options = Reflect.getMetadata('queue:options', event);
|
|
86
68
|
const self = this;
|
|
87
69
|
if (!options) {
|
|
88
|
-
throw new
|
|
70
|
+
throw new InvalidArgument(`Type ${event.name} is not defined as Job or Event type. Use proper decorator to configure queue events`);
|
|
89
71
|
}
|
|
90
72
|
const { durable: eDurable } = options;
|
|
91
73
|
const connections = this.getConnectionsForMessage(event);
|
|
92
74
|
if ((eDurable || durable) && !subscriptionId) {
|
|
93
|
-
throw new
|
|
75
|
+
throw new InvalidArgument('subscriptionId should be set when using durable events');
|
|
94
76
|
}
|
|
95
77
|
for (let c of connections) {
|
|
96
78
|
const conn = this.Connections.get(c);
|
|
97
79
|
if (!conn) {
|
|
98
|
-
throw new
|
|
80
|
+
throw new ServiceNotFound(`Queue connection ${c} not found. Please check your configuration before consuming events from this connection.`);
|
|
99
81
|
}
|
|
100
82
|
await conn.subscribe(event, async (e) => {
|
|
101
83
|
if (e.Name === event.name) {
|
|
102
|
-
const ev =
|
|
84
|
+
const ev = DI.resolve(event);
|
|
103
85
|
ev.hydrate(e);
|
|
104
86
|
/**
|
|
105
87
|
* Handle job type of message
|
|
106
88
|
* To preserve result & handle delay, errors etc..
|
|
107
89
|
*/
|
|
108
|
-
if (ev instanceof
|
|
90
|
+
if (ev instanceof QueueJob) {
|
|
109
91
|
let jobResult = null;
|
|
110
|
-
const jModel = await
|
|
92
|
+
const jModel = await JobModel.where({ JobId: ev.JobId }).firstOrThrow(new UnexpectedServerError(`No model found for jobId ${ev.JobId}`));
|
|
111
93
|
jModel.Status = 'executing';
|
|
112
|
-
jModel.ExecutedAt =
|
|
94
|
+
jModel.ExecutedAt = DateTime.now();
|
|
113
95
|
try {
|
|
114
96
|
// update executing state
|
|
115
97
|
await jModel.update();
|
|
116
98
|
jobResult = await ev.execute(onProgress);
|
|
117
99
|
jModel.Result = jobResult;
|
|
118
100
|
jModel.Status = 'success';
|
|
119
|
-
jModel.FinishedAt =
|
|
101
|
+
jModel.FinishedAt = DateTime.now();
|
|
120
102
|
jModel.Progress = 100;
|
|
121
103
|
this.Log.trace(`Job ${event.name} processed with result ${JSON.stringify(jModel.Result)}`);
|
|
122
104
|
}
|
|
@@ -134,15 +116,15 @@ let DefaultQueueService = class DefaultQueueService extends interfaces_1.QueueSe
|
|
|
134
116
|
self.Log.trace(`Job ${event.name}:${jModel.JobId} progress: ${p}%`);
|
|
135
117
|
}
|
|
136
118
|
}
|
|
137
|
-
if (!callback && ev instanceof
|
|
138
|
-
throw new
|
|
119
|
+
if (!callback && ev instanceof QueueEvent) {
|
|
120
|
+
throw new InvalidArgument('when subscribing to events, callback cannot be null. Subscriber should handle event in callback function !');
|
|
139
121
|
}
|
|
140
122
|
this.Log.trace(`Queue message ${event.name} processed`);
|
|
141
123
|
if (callback) {
|
|
142
124
|
return callback(ev);
|
|
143
125
|
}
|
|
144
126
|
}
|
|
145
|
-
}, subscriptionId,
|
|
127
|
+
}, subscriptionId, durable ?? eDurable ?? false);
|
|
146
128
|
}
|
|
147
129
|
}
|
|
148
130
|
/**
|
|
@@ -151,19 +133,19 @@ let DefaultQueueService = class DefaultQueueService extends interfaces_1.QueueSe
|
|
|
151
133
|
* @returns
|
|
152
134
|
*/
|
|
153
135
|
get(connection) {
|
|
154
|
-
return this.Connections.get(`${connection
|
|
136
|
+
return this.Connections.get(`${connection ?? this.Configuration.default}`);
|
|
155
137
|
}
|
|
156
138
|
};
|
|
157
139
|
__decorate([
|
|
158
|
-
|
|
159
|
-
__metadata("design:type",
|
|
140
|
+
Logger('queue'),
|
|
141
|
+
__metadata("design:type", Log)
|
|
160
142
|
], DefaultQueueService.prototype, "Log", void 0);
|
|
161
143
|
__decorate([
|
|
162
|
-
|
|
144
|
+
AutoinjectService('queue.connections', QueueClient),
|
|
163
145
|
__metadata("design:type", Map)
|
|
164
146
|
], DefaultQueueService.prototype, "Connections", void 0);
|
|
165
147
|
DefaultQueueService = __decorate([
|
|
166
|
-
|
|
148
|
+
Injectable(QueueService)
|
|
167
149
|
], DefaultQueueService);
|
|
168
|
-
|
|
150
|
+
export { DefaultQueueService };
|
|
169
151
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAe,EAAE,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAA+B,YAAY,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACtH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2CAA2C,CAAC;AAGnD,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,YAAY;IAO5C,KAAK,CAAC,OAAO;QAClB,IAAI,CAAC,WAAW,CAAC,O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AAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,IAAI,EAAE,OAAO,GAAG,KAAK,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;;;;OAKG;IACH,6BAA6B,CAAC,EAAE,MAAM,CAAC;CACxC;AAED,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;CACtB"}
|
package/lib/interfaces.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -8,31 +7,25 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const luxon_1 = require("luxon");
|
|
18
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
19
|
-
const log_1 = require("@spinajs/log");
|
|
20
|
-
const configuration_1 = require("@spinajs/configuration");
|
|
21
|
-
var QueueMessageType;
|
|
10
|
+
import { AsyncService, DI } from '@spinajs/di';
|
|
11
|
+
import { DateTime } from 'luxon';
|
|
12
|
+
import _ from 'lodash';
|
|
13
|
+
import { Log, Logger } from '@spinajs/log';
|
|
14
|
+
import { Config } from '@spinajs/configuration';
|
|
15
|
+
export var QueueMessageType;
|
|
22
16
|
(function (QueueMessageType) {
|
|
23
17
|
QueueMessageType["Job"] = "JOB";
|
|
24
18
|
QueueMessageType["Event"] = "EVENT";
|
|
25
|
-
})(QueueMessageType
|
|
26
|
-
class QueueService extends
|
|
19
|
+
})(QueueMessageType || (QueueMessageType = {}));
|
|
20
|
+
export class QueueService extends AsyncService {
|
|
27
21
|
getConnectionsForMessage(event) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (lodash_1.default.isString(option)) {
|
|
22
|
+
const option = this.Configuration.routing[event.Name ?? event.name] ?? this.Configuration.default;
|
|
23
|
+
if (_.isString(option)) {
|
|
31
24
|
return [this.Configuration.default];
|
|
32
25
|
}
|
|
33
|
-
if (
|
|
34
|
-
return
|
|
35
|
-
if (
|
|
26
|
+
if (_.isArray(option)) {
|
|
27
|
+
return _.uniq(option.map((x) => {
|
|
28
|
+
if (_.isString(x)) {
|
|
36
29
|
return this.Configuration.default;
|
|
37
30
|
}
|
|
38
31
|
if (x.connection) {
|
|
@@ -43,26 +36,23 @@ class QueueService extends di_1.AsyncService {
|
|
|
43
36
|
}
|
|
44
37
|
}
|
|
45
38
|
__decorate([
|
|
46
|
-
|
|
39
|
+
Config('queue'),
|
|
47
40
|
__metadata("design:type", Object)
|
|
48
41
|
], QueueService.prototype, "Configuration", void 0);
|
|
49
|
-
|
|
50
|
-
function isJob(event) {
|
|
42
|
+
export function isJob(event) {
|
|
51
43
|
return event.Type === QueueMessageType.Job;
|
|
52
44
|
}
|
|
53
|
-
exports.isJob = isJob;
|
|
54
45
|
/**
|
|
55
46
|
* Events are messages send via queue, we do not want to track it, dont care about result, no retry policy on failed execution etc.
|
|
56
47
|
*/
|
|
57
|
-
class QueueMessage {
|
|
48
|
+
export class QueueMessage {
|
|
58
49
|
constructor() {
|
|
59
|
-
this.CreatedAt =
|
|
50
|
+
this.CreatedAt = DateTime.now();
|
|
60
51
|
}
|
|
61
52
|
hydrate(payload) {
|
|
62
53
|
Object.assign(this, payload);
|
|
63
54
|
}
|
|
64
55
|
}
|
|
65
|
-
exports.QueueMessage = QueueMessage;
|
|
66
56
|
/**
|
|
67
57
|
* events provides a simple observer implementation, allowing you to subscribe and listen
|
|
68
58
|
* for various events that occur in your application. Events serve as a great way to decouple
|
|
@@ -71,52 +61,60 @@ exports.QueueMessage = QueueMessage;
|
|
|
71
61
|
* we can register multiple listeners for a single event and the event helper will dispatch the event to all of its registered
|
|
72
62
|
* listeners without us calling them explicitly. where in case of Jobs we would have to call them each one explicitly.
|
|
73
63
|
*/
|
|
74
|
-
class QueueEvent extends QueueMessage {
|
|
64
|
+
export class QueueEvent extends QueueMessage {
|
|
75
65
|
constructor() {
|
|
76
66
|
super();
|
|
77
67
|
this.Type = QueueMessageType.Event;
|
|
78
68
|
}
|
|
79
69
|
static async emit(val, options) {
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
70
|
+
const queue = await DI.resolve(QueueService);
|
|
71
|
+
const message = {
|
|
72
|
+
...val,
|
|
73
|
+
Type: QueueMessageType.Event,
|
|
74
|
+
CreatedAt: val.CreatedAt ?? DateTime.now(),
|
|
75
|
+
Name: this.name,
|
|
76
|
+
...options,
|
|
77
|
+
};
|
|
83
78
|
// partial of queue job always is queue message
|
|
84
79
|
await queue.emit(message);
|
|
85
80
|
}
|
|
86
81
|
}
|
|
87
|
-
exports.QueueEvent = QueueEvent;
|
|
88
82
|
/**
|
|
89
83
|
* Jobs are executed only once even if multiple listeners waiting for it. usually used for single method call
|
|
90
84
|
* or time consuming tasks, that need to checked for result and tracked
|
|
91
85
|
*
|
|
92
86
|
* Job results are preserved
|
|
93
87
|
*/
|
|
94
|
-
class QueueJob extends QueueMessage {
|
|
88
|
+
export class QueueJob extends QueueMessage {
|
|
95
89
|
constructor() {
|
|
96
90
|
super();
|
|
97
91
|
this.Type = QueueMessageType.Job;
|
|
98
92
|
this.Name = this.constructor.name;
|
|
99
93
|
}
|
|
100
94
|
static async emit(val, options) {
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
|
|
95
|
+
const queue = await DI.resolve(QueueService);
|
|
96
|
+
const message = {
|
|
97
|
+
...val,
|
|
98
|
+
Type: QueueMessageType.Job,
|
|
99
|
+
CreatedAt: val.CreatedAt ?? DateTime.now(),
|
|
100
|
+
Name: this.name,
|
|
101
|
+
...options,
|
|
102
|
+
};
|
|
104
103
|
// partial of queue job always is queue message
|
|
105
104
|
await queue.emit(message);
|
|
106
105
|
}
|
|
107
106
|
}
|
|
108
|
-
|
|
109
|
-
class QueueClient extends di_1.AsyncService {
|
|
110
|
-
constructor(Options) {
|
|
111
|
-
super();
|
|
112
|
-
this.Options = Options;
|
|
113
|
-
}
|
|
107
|
+
export class QueueClient extends AsyncService {
|
|
114
108
|
get Name() {
|
|
115
109
|
return this.Options.name;
|
|
116
110
|
}
|
|
117
111
|
get ServiceName() {
|
|
118
112
|
return this.Options.name;
|
|
119
113
|
}
|
|
114
|
+
constructor(Options) {
|
|
115
|
+
super();
|
|
116
|
+
this.Options = Options;
|
|
117
|
+
}
|
|
120
118
|
__checkInstance__(creationOptions) {
|
|
121
119
|
return this.Options.name === creationOptions[0].name;
|
|
122
120
|
}
|
|
@@ -127,36 +125,33 @@ class QueueClient extends di_1.AsyncService {
|
|
|
127
125
|
* @param event - event to check
|
|
128
126
|
*/
|
|
129
127
|
getChannelForMessage(event) {
|
|
130
|
-
var _a, _b;
|
|
131
128
|
const options = Reflect.getMetadata('queue:options', event);
|
|
132
|
-
const eName =
|
|
129
|
+
const eName = event.Name ?? event.name;
|
|
133
130
|
const isJob = event.Type ? event.Type === QueueMessageType.Job : options ? options.type === 'job' : false;
|
|
134
131
|
const rOption = this.Routing[eName];
|
|
135
132
|
if (!rOption) {
|
|
136
133
|
return [isJob ? this.Options.defaultQueueChannel : this.Options.defaultTopicChannel];
|
|
137
134
|
}
|
|
138
|
-
if (
|
|
135
|
+
if (_.isString(rOption)) {
|
|
139
136
|
return [rOption];
|
|
140
137
|
}
|
|
141
|
-
if (
|
|
142
|
-
return
|
|
143
|
-
|
|
144
|
-
if (lodash_1.default.isString(x)) {
|
|
138
|
+
if (_.isArray(rOption)) {
|
|
139
|
+
return _.uniq(rOption.map((x) => {
|
|
140
|
+
if (_.isString(x)) {
|
|
145
141
|
return x;
|
|
146
142
|
}
|
|
147
|
-
return
|
|
143
|
+
return x.channel ?? isJob ? this.Options.defaultQueueChannel : this.Options.defaultTopicChannel;
|
|
148
144
|
}));
|
|
149
145
|
}
|
|
150
|
-
return [
|
|
146
|
+
return [rOption.channel ?? isJob ? this.Options.defaultQueueChannel : this.Options.defaultTopicChannel];
|
|
151
147
|
}
|
|
152
148
|
}
|
|
153
149
|
__decorate([
|
|
154
|
-
|
|
155
|
-
__metadata("design:type",
|
|
150
|
+
Logger('queue'),
|
|
151
|
+
__metadata("design:type", Log)
|
|
156
152
|
], QueueClient.prototype, "Log", void 0);
|
|
157
153
|
__decorate([
|
|
158
|
-
|
|
154
|
+
Config('queue.routing'),
|
|
159
155
|
__metadata("design:type", Object)
|
|
160
156
|
], QueueClient.prototype, "Routing", void 0);
|
|
161
|
-
exports.QueueClient = QueueClient;
|
|
162
157
|
//# sourceMappingURL=interfaces.js.map
|
package/lib/interfaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAe,EAAE,EAAoC,MAAM,aAAa,CAAC;AAC9F,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,CAAC,MAAM,QAAQ,CAAC;AACvB,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD,MAAM,CAAN,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,+BAAW,CAAA;IACX,mCAAe,CAAA;AACjB,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B;AAgCD,MAAM,OAAgB,YAAa,SAAQ,YAAY;IAS3C,wBAAwB,CAAC,KAAgD;QACjF,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAE,KAAuB,CAAC,IAAI,IAAK,KAAmC,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;QAEpJ,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;YACtB,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;SACrC;QAED,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACrB,OAAO,CAAC,CAAC,IAAI,CACX,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;gBACf,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;oBACjB,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;iBACnC;gBAED,IAAI,CAAC,CAAC,UAAU,EAAE;oBAChB,OAAO,CAAC,CAAC,UAAU,CAAC;iBACrB;YACH,CAAC,CAAC,CACH,C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AAElE,qBACa,yBAA0B,SAAQ,YAAY;IAC5C,EAAE,CAAC,UAAU,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBxC,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;CACzD"}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
4
|
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
6
|
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.Queue_2022_10_18_01_13_00 = void 0;
|
|
10
7
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
11
|
-
|
|
12
|
-
let Queue_2022_10_18_01_13_00 = class Queue_2022_10_18_01_13_00 extends
|
|
8
|
+
import { OrmMigration, Migration } from '@spinajs/orm';
|
|
9
|
+
let Queue_2022_10_18_01_13_00 = class Queue_2022_10_18_01_13_00 extends OrmMigration {
|
|
13
10
|
async up(connection) {
|
|
14
11
|
await connection.schema().createTable('queue_jobs', (table) => {
|
|
15
12
|
table.int('Id').primaryKey().autoIncrement();
|
|
@@ -30,7 +27,7 @@ let Queue_2022_10_18_01_13_00 = class Queue_2022_10_18_01_13_00 extends orm_1.Or
|
|
|
30
27
|
async down(_connection) { }
|
|
31
28
|
};
|
|
32
29
|
Queue_2022_10_18_01_13_00 = __decorate([
|
|
33
|
-
|
|
30
|
+
Migration('queue')
|
|
34
31
|
], Queue_2022_10_18_01_13_00);
|
|
35
|
-
|
|
32
|
+
export { Queue_2022_10_18_01_13_00 };
|
|
36
33
|
//# sourceMappingURL=Queue_2022_10_18_01_13_00.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Queue_2022_10_18_01_13_00.js","sourceRoot":"","sources":["../../src/migrations/Queue_2022_10_18_01_13_00.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Queue_2022_10_18_01_13_00.js","sourceRoot":"","sources":["../../src/migrations/Queue_2022_10_18_01_13_00.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAsD;AACtD,OAAO,EAAE,YAAY,EAAa,SAAS,EAAE,MAAM,cAAc,CAAC;AAG3D,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,YAAY;IAClD,KAAK,CAAC,EAAE,CAAC,UAAqB;QACnC,MAAM,UAAU,CAAC,MAAM,EAAE,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE;YAC5D,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC,aAAa,EAAE,CAAC;YAC7C,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC;YAC9B,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;YACnC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YACvB,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YACxG,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACnD,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,O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AAQ,CAAC;CAC7B"}
|
package/lib/models/JobModel.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -8,40 +7,38 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const luxon_1 = require("luxon");
|
|
14
|
-
const orm_1 = require("@spinajs/orm");
|
|
10
|
+
import { DateTime } from 'luxon';
|
|
11
|
+
import { ModelBase, Connection, Model, Json, CreatedAt, DateTime as DT, Primary } from '@spinajs/orm';
|
|
15
12
|
/**
|
|
16
13
|
* Base modele for users used by ACL
|
|
17
14
|
*
|
|
18
15
|
* To add / extend fields simply extend this model and register as default user model in ACL service
|
|
19
16
|
*/
|
|
20
|
-
let JobModel = class JobModel extends
|
|
17
|
+
let JobModel = class JobModel extends ModelBase {
|
|
21
18
|
};
|
|
22
19
|
__decorate([
|
|
23
|
-
|
|
20
|
+
Primary(),
|
|
24
21
|
__metadata("design:type", Number)
|
|
25
22
|
], JobModel.prototype, "Id", void 0);
|
|
26
23
|
__decorate([
|
|
27
|
-
|
|
24
|
+
Json(),
|
|
28
25
|
__metadata("design:type", Object)
|
|
29
26
|
], JobModel.prototype, "Result", void 0);
|
|
30
27
|
__decorate([
|
|
31
|
-
|
|
32
|
-
__metadata("design:type",
|
|
28
|
+
CreatedAt(),
|
|
29
|
+
__metadata("design:type", DateTime)
|
|
33
30
|
], JobModel.prototype, "CreatedAt", void 0);
|
|
34
31
|
__decorate([
|
|
35
|
-
(
|
|
36
|
-
__metadata("design:type",
|
|
32
|
+
DT(),
|
|
33
|
+
__metadata("design:type", DateTime)
|
|
37
34
|
], JobModel.prototype, "ExecutedAt", void 0);
|
|
38
35
|
__decorate([
|
|
39
|
-
(
|
|
40
|
-
__metadata("design:type",
|
|
36
|
+
DT(),
|
|
37
|
+
__metadata("design:type", DateTime)
|
|
41
38
|
], JobModel.prototype, "FinishedAt", void 0);
|
|
42
39
|
JobModel = __decorate([
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
Connection('queue'),
|
|
41
|
+
Model('queue_jobs')
|
|
45
42
|
], JobModel);
|
|
46
|
-
|
|
43
|
+
export { JobModel };
|
|
47
44
|
//# sourceMappingURL=JobModel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JobModel.js","sourceRoot":"","sources":["../../src/models/JobModel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"JobModel.js","sourceRoot":"","sources":["../../src/models/JobModel.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEtG;;;;GAIG;AAGI,IAAM,QAAQ,GAAd,MAAM,QAAY,SAAQ,SAAS;CAyBzC,CAAA;AAxBC;IAAC,OAAO,EAAE;;oCACQ;AAMlB;IAAC,IAAI,EAAE;;wCACU;AAQjB;IAAC,SAAS,EAAE;8BACM,QAAQ;2CAAC;AAE3B;IAAC,EAAE,EAAE;8BACc,QAAQ;4CAAC;AAE5B;IAAC,EAAE,EAAE;8BACc,QAAQ;4CAAC;AAxBjB,QAAQ;IAFpB,UAAU,CAAC,OAAO,CAAC;IACnB,KAAK,CAAC,YAAY,CAAC;GACP,QAAQ,CAyBpB;SAzBY,QAAQ"}
|
package/package.json
CHANGED
|
@@ -1,53 +1,56 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@spinajs/queue",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "queue sending & pulling made easy",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"spinajs"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"@
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"@spinajs/
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@spinajs/queue",
|
|
3
|
+
"version": "2.0.50",
|
|
4
|
+
"description": "queue sending & pulling made easy",
|
|
5
|
+
"exports": "./lib/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"private": false,
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=16.11"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "npm run clean && npm run compile",
|
|
13
|
+
"compile": "tsc -b tsconfig.json",
|
|
14
|
+
"rimraf": "./node_modules/rimraf/bin.js",
|
|
15
|
+
"clean": "rimraf lib/ && rimraf tsconfig.tsbuildinfo",
|
|
16
|
+
"test": "ts-mocha -p tsconfig.json test/**/*.test.ts",
|
|
17
|
+
"coverage": "nyc npm run test",
|
|
18
|
+
"build-docs": "rimraf docs && typedoc --options typedoc.json src/",
|
|
19
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
20
|
+
"lint": "eslint -c .eslintrc.cjs --ext .ts src --fix",
|
|
21
|
+
"preversion": "npm run lint",
|
|
22
|
+
"version": "npm run format && git add -A src",
|
|
23
|
+
"postinstall": "npm run build"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"lib/**/*"
|
|
27
|
+
],
|
|
28
|
+
"types": "lib",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/spinajs/main.git"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"spinajs",
|
|
35
|
+
"http"
|
|
36
|
+
],
|
|
37
|
+
"author": "SpinaJS <spinajs@coderush.pl> (https://github.com/spinajs/main)",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/spinajs/main/issues"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/spinajs/main#readme",
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/luxon": "^3.2.0",
|
|
45
|
+
"@types/node": "^18.11.18"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@spinajs/configuration": "^2.0.46",
|
|
49
|
+
"@spinajs/di": "^2.0.46",
|
|
50
|
+
"@spinajs/exceptions": "^2.0.39",
|
|
51
|
+
"@spinajs/log": "^2.0.46",
|
|
52
|
+
"@spinajs/orm": "^2.0.46",
|
|
53
|
+
"luxon": "^3.2.1"
|
|
54
|
+
},
|
|
55
|
+
"gitHead": "002dc553b0ffffd72193d0121ac425a4083bc9ee"
|
|
56
|
+
}
|
package/lib/bootstrap.d.ts
DELETED
package/lib/bootstrap.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
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.QueueBootstrapper = void 0;
|
|
10
|
-
/* eslint-disable @typescript-eslint/require-await */
|
|
11
|
-
const di_1 = require("@spinajs/di");
|
|
12
|
-
const Queue_2022_10_18_01_13_00_1 = require("./migrations/Queue_2022_10_18_01_13_00");
|
|
13
|
-
const JobModel_1 = require("./models/JobModel");
|
|
14
|
-
let QueueBootstrapper = class QueueBootstrapper extends di_1.Bootstrapper {
|
|
15
|
-
async bootstrap() {
|
|
16
|
-
di_1.DI.register(JobModel_1.JobModel).asValue('__models__');
|
|
17
|
-
di_1.DI.register(Queue_2022_10_18_01_13_00_1.Queue_2022_10_18_01_13_00).asValue('__migrations__');
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
QueueBootstrapper = __decorate([
|
|
22
|
-
(0, di_1.Injectable)(di_1.Bootstrapper)
|
|
23
|
-
], QueueBootstrapper);
|
|
24
|
-
exports.QueueBootstrapper = QueueBootstrapper;
|
|
25
|
-
//# sourceMappingURL=bootstrap.js.map
|
package/lib/bootstrap.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":";;;;;;;;;AAAA,qDAAqD;AACrD,oCAA2D;AAC3D,sFAAmF;AACnF,gDAA6C;AAG7C,IAAa,iBAAiB,GAA9B,MAAa,iBAAkB,SAAQ,iBAAY;IAC1C,KAAK,CAAC,SAAS;QACpB,OAAE,CAAC,QAAQ,CAAC,mBAAQ,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC5C,OAAE,CAAC,QAAQ,CAAC,qDAAyB,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QACjE,OAAO;IACT,CAAC;CACF,CAAA;AANY,iBAAiB;IAD7B,IAAA,eAAU,EAAC,iBAAY,CAAC;GACZ,iBAAiB,CAM7B;AANY,8CAAiB"}
|