@midwayjs/bullmq 0.0.2 → 3.20.2

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2013 - Now midwayjs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -13,6 +13,7 @@ export declare class BullMQQueue extends Queue {
13
13
  getQueueEventsList(): QueueEvents[];
14
14
  createQueueEventsProducer(options?: QueueBaseOptions): QueueEventsProducer;
15
15
  getQueueEventsProducerList(): QueueEventsProducer[];
16
+ close(): Promise<void>;
16
17
  }
17
18
  export declare class BullMQFramework extends BaseFramework<Application, Context, any> {
18
19
  private defaultConnection;
package/dist/framework.js CHANGED
@@ -60,6 +60,12 @@ class BullMQQueue extends bullmq_1.Queue {
60
60
  getQueueEventsProducerList() {
61
61
  return this.queueEventsProducerList;
62
62
  }
63
+ async close() {
64
+ // 并发关闭
65
+ await Promise.all(this.queueEventsList.map(evt => evt.close()));
66
+ await Promise.all(this.queueEventsProducerList.map(producer => producer.close()));
67
+ await super.close();
68
+ }
63
69
  }
64
70
  exports.BullMQQueue = BullMQQueue;
65
71
  let BullMQFramework = class BullMQFramework extends core_1.BaseFramework {
@@ -124,27 +130,15 @@ let BullMQFramework = class BullMQFramework extends core_1.BaseFramework {
124
130
  }
125
131
  async beforeStop() {
126
132
  // loop queueMap and stop all queue
127
- for (const queue of this.queueMap.values()) {
128
- await queue.close();
129
- }
130
- for (const worker of this.workerMap.values()) {
131
- for (const w of worker) {
132
- await w.close();
133
- }
134
- }
135
- for (const producer of this.flowProducerMap.values()) {
136
- await producer.close();
137
- }
133
+ await Promise.all(Array.from(this.queueMap.values()).map(queue => queue.close()));
134
+ await Promise.all(Array.from(this.workerMap.values()).map(worker => worker.map(w => w.close())));
135
+ await Promise.all(Array.from(this.flowProducerMap.values()).map(producer => producer.close()));
138
136
  }
139
137
  /**
140
138
  * Create a queue with name and queueOptions
141
139
  */
142
140
  createQueue(name, queueOptions = {}) {
143
- const mergedOptions = {
144
- ...this.defaultQueueConfig,
145
- ...this.defaultConnection,
146
- ...queueOptions,
147
- };
141
+ const mergedOptions = (0, core_1.extend)(true, {}, this.defaultQueueConfig, this.defaultConnection, queueOptions);
148
142
  const queue = new BullMQQueue(name, mergedOptions);
149
143
  this.queueMap.set(name, queue);
150
144
  queue.on('error', err => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@midwayjs/bullmq",
3
- "version": "0.0.2",
4
- "description": "midway component for bullMQ",
3
+ "version": "3.20.2",
4
+ "description": "midway component for BullMQ",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
7
7
  "scripts": {
@@ -13,7 +13,7 @@
13
13
  "midway",
14
14
  "IoC",
15
15
  "task",
16
- "bullmq",
16
+ "BullMQ",
17
17
  "plugin"
18
18
  ],
19
19
  "author": "guo qicong",
@@ -24,14 +24,15 @@
24
24
  ],
25
25
  "license": "MIT",
26
26
  "devDependencies": {
27
- "@midwayjs/core": "^3.19.0",
28
- "@midwayjs/mock": "^3.19.2"
27
+ "@midwayjs/core": "^3.20.0",
28
+ "@midwayjs/mock": "^3.20.0"
29
29
  },
30
30
  "dependencies": {
31
- "bullmq": "5.34.6"
31
+ "bullmq": "5.39.1"
32
32
  },
33
33
  "engines": {
34
34
  "node": ">=12"
35
35
  },
36
- "repository": "https://github.com/midwayjs/midway.git"
36
+ "repository": "https://github.com/midwayjs/midway.git",
37
+ "gitHead": "f7b70a56947c48c820001f9ff5bc1071f7e94b09"
37
38
  }