keuss 1.7.1 → 1.7.3
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 +21 -674
- package/QFactory-MongoDB-defaults.js +1 -1
- package/Queue.js +2 -2
- package/TODO +8 -0
- package/backends/intraorder.js +374 -0
- package/docker-compose.yaml +18 -0
- package/package.json +9 -9
- package/playground/irc.js +53 -0
- package/test/backends_deadletter.js +7 -6
- package/test/backends_payload.js +8 -7
- package/test/backends_reserve-commit-rollback.js +32 -13
- package/test/intraorder.js +325 -0
- package/test/pause.js +1 -0
|
@@ -11,7 +11,7 @@ class QFactory_MongoDB_defaults extends QFactory {
|
|
|
11
11
|
super (opts);
|
|
12
12
|
|
|
13
13
|
if (!this._opts.url) {
|
|
14
|
-
this._opts.url = '
|
|
14
|
+
this._opts.url = 'mongodb://localhost:27017/keuss';
|
|
15
15
|
debug ('added url default to %s: %o', this._name, this._opts.url);
|
|
16
16
|
}
|
|
17
17
|
|
package/Queue.js
CHANGED
package/TODO
CHANGED
|
@@ -8,6 +8,14 @@ prio 1
|
|
|
8
8
|
* pipelines
|
|
9
9
|
+ add some commonplace transforms (etl-like)
|
|
10
10
|
+ create a server for that, allow processor code defined externally
|
|
11
|
+
* documentation
|
|
12
|
+
+ blog entries:
|
|
13
|
+
- motivations on using mongodb+redis. comparatives, pros&cons
|
|
14
|
+
- buckets
|
|
15
|
+
- pipelines
|
|
16
|
+
- tape
|
|
17
|
+
- redis-oq
|
|
18
|
+
- exotic experiments: intraorder
|
|
11
19
|
|
|
12
20
|
prio 0
|
|
13
21
|
-----------------------------------------------------------------
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
const _ = require ('lodash');
|
|
2
|
+
const async = require ('async');
|
|
3
|
+
const uuid = require ('uuid');
|
|
4
|
+
|
|
5
|
+
const MongoClient = require ('mongodb').MongoClient;
|
|
6
|
+
const mongo = require ('mongodb');
|
|
7
|
+
|
|
8
|
+
const Queue = require ('../Queue');
|
|
9
|
+
const QFactory_MongoDB_defaults = require ('../QFactory-MongoDB-defaults');
|
|
10
|
+
|
|
11
|
+
const debug = require('debug')('keuss:Queue:intraqueue');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class IntraOrderedQueue extends Queue {
|
|
15
|
+
|
|
16
|
+
//////////////////////////////////////////////
|
|
17
|
+
constructor (name, factory, opts, orig_opts) {
|
|
18
|
+
super (name, factory, opts, orig_opts);
|
|
19
|
+
|
|
20
|
+
this._factory = factory;
|
|
21
|
+
this._col = factory._db.collection (name);
|
|
22
|
+
this.ensureIndexes (err => {});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/////////////////////////////////////////
|
|
27
|
+
static Type () {
|
|
28
|
+
return 'mongo:intraorder';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
/////////////////////////////////////////
|
|
33
|
+
type () {
|
|
34
|
+
return 'mongo:intraorder';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
/////////////////////////////////////////
|
|
39
|
+
// add element to queue
|
|
40
|
+
insert (entry, callback) {
|
|
41
|
+
const q = { _id: entry.payload.iid || uuid.v4 () };
|
|
42
|
+
const upd = {
|
|
43
|
+
$push: { q: entry },
|
|
44
|
+
$inc: { qcnt: 1 },
|
|
45
|
+
$set: { mature: entry.mature, tries: entry.tries },
|
|
46
|
+
};
|
|
47
|
+
const opts = { upsert: true };
|
|
48
|
+
|
|
49
|
+
this._col.updateOne (q, upd, opts, (err, result) => {
|
|
50
|
+
debug ('insert: updateOne (%j, %j, %j) => (%j, %j)', q, upd, opts, err, result);
|
|
51
|
+
if (err) return callback (err);
|
|
52
|
+
// TODO result.insertedCount must be 1
|
|
53
|
+
callback (null, result.upsertedId || q._id);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
/////////////////////////////////////////
|
|
59
|
+
// get element from queue
|
|
60
|
+
get (callback) {
|
|
61
|
+
// actually, a reserve followed by a commit
|
|
62
|
+
this.reserve ((err, elem) => {
|
|
63
|
+
if (err) return callback (err);
|
|
64
|
+
if (!elem) return callback ();
|
|
65
|
+
|
|
66
|
+
this.commit (elem._id, (err, res) => {
|
|
67
|
+
if (err) return callback (err);
|
|
68
|
+
|
|
69
|
+
// clear _env: not needed here
|
|
70
|
+
delete elem._env;
|
|
71
|
+
callback (null, elem);
|
|
72
|
+
}, elem);
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
//////////////////////////////////
|
|
78
|
+
// reserve element: call cb (err, pl) where pl has an id
|
|
79
|
+
reserve (callback) {
|
|
80
|
+
const delay = this._opts.reserve_delay || 120;
|
|
81
|
+
|
|
82
|
+
const q = {
|
|
83
|
+
mature: {$lte: Queue.nowPlusSecs (0)},
|
|
84
|
+
qcnt: { $gt: 0}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const upd = {
|
|
88
|
+
$set: {
|
|
89
|
+
mature: Queue.nowPlusSecs (delay),
|
|
90
|
+
reserved: new Date ()
|
|
91
|
+
},
|
|
92
|
+
$inc: {tries: 1}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const opts = {
|
|
96
|
+
sort: {mature : 1},
|
|
97
|
+
returnDocument: 'before'
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
this._col.findOneAndUpdate (q, upd, opts, (err, result) => {
|
|
101
|
+
debug ('reserve: findOneAndUpdate (%j, %j, %j) => (%j, %j)', q, upd, opts, err, result);
|
|
102
|
+
if (err) return callback (err);
|
|
103
|
+
const v = result && result.value;
|
|
104
|
+
if (!v) return callback ();
|
|
105
|
+
|
|
106
|
+
// construct the real object to return
|
|
107
|
+
const vq = v.q[0];
|
|
108
|
+
vq._id = v._id; // use the whole obj's _id
|
|
109
|
+
vq.tries = v.tries
|
|
110
|
+
vq._env = v; // pass along the whole obj too
|
|
111
|
+
if (vq.payload._bsontype == 'Binary') vq.payload = vq.payload.buffer;
|
|
112
|
+
callback (null, vq);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
//////////////////////////////////
|
|
118
|
+
// commit previous reserve, by p.id
|
|
119
|
+
commit (id, callback, obj) {
|
|
120
|
+
if (!(obj || (obj && obj._id))) {
|
|
121
|
+
// full obj must be passed to commit
|
|
122
|
+
return callback ('full obj must be passed to commit');
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const q = {
|
|
126
|
+
_id: id,
|
|
127
|
+
reserved: {$exists: true}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const upd = {
|
|
131
|
+
// do not alter mature on commit: leave it be
|
|
132
|
+
// $set: {
|
|
133
|
+
// mature: Queue.nowPlusSecs (100 * this._opts.ttl)
|
|
134
|
+
// },
|
|
135
|
+
$pop: {q: -1}, // pop entry from queue
|
|
136
|
+
$inc: { qcnt: -1 }, // one less element
|
|
137
|
+
$unset: {reserved: ''}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
if ((obj._env && obj._env.qcnt) > 1) {
|
|
141
|
+
debug ('it is certain there are still entries in the intraqueue: set mature and tries');
|
|
142
|
+
upd.$set = {
|
|
143
|
+
mature: obj._env.q[1].mature,
|
|
144
|
+
tries: obj._env.q[1].tries,
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
// last in queue: set mature to distant future to get it out of the way while it's GCed
|
|
149
|
+
// not really, it'd impact if there were an insert in between
|
|
150
|
+
// upd.$set.mature = Queue.nowPlusSecs (60*60*24*1000);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const opts = {};
|
|
154
|
+
|
|
155
|
+
this._col.updateOne (q, upd, opts, (err, result) => {
|
|
156
|
+
debug ('commit: updateOne (%j, %j, %j) => (%j, %j)', q, upd, opts, err, result);
|
|
157
|
+
if (err) return callback (err);
|
|
158
|
+
callback (null, result && (result.modifiedCount == 1));
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
//////////////////////////////////
|
|
164
|
+
// rollback previous reserve, by p.id
|
|
165
|
+
rollback (id, next_t, callback) {
|
|
166
|
+
if (_.isFunction (next_t)) {
|
|
167
|
+
callback = next_t;
|
|
168
|
+
next_t = null;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const q = {
|
|
172
|
+
_id: id,
|
|
173
|
+
reserved: {$exists: true}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const upd = {
|
|
177
|
+
$set: {mature: (next_t ? new Date (next_t) : Queue.now ())},
|
|
178
|
+
$unset: {reserved: ''}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const opts = {};
|
|
182
|
+
|
|
183
|
+
this._col.updateOne (q, upd, opts, (err, result) => {
|
|
184
|
+
debug ('rollback: updateOne (%j, %j, %j) => (%j, %j)', q, upd, opts, err, result);
|
|
185
|
+
if (err) return callback (err);
|
|
186
|
+
callback (null, result && (result.modifiedCount == 1));
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
//////////////////////////////////
|
|
192
|
+
// queue size of non-mature elements only
|
|
193
|
+
totalSize (callback) {
|
|
194
|
+
const cursor = this._col.aggregate ([
|
|
195
|
+
{$match: {
|
|
196
|
+
qcnt: {$gt: 0}
|
|
197
|
+
}},
|
|
198
|
+
{$group:{_id:'t', v: {$sum: '$qcnt'}}}
|
|
199
|
+
]);
|
|
200
|
+
|
|
201
|
+
cursor.toArray ((err, res) => {
|
|
202
|
+
debug ('calculating schedSize: aggregation pipeline returns %o', res);
|
|
203
|
+
if (err) return callback (err);
|
|
204
|
+
if (res.length == 0) return callback (null, 0);
|
|
205
|
+
callback (null, res[0].v);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
//////////////////////////////////
|
|
211
|
+
// queue size NOT including non-mature elements
|
|
212
|
+
size (callback) {
|
|
213
|
+
const cursor = this._col.aggregate ([
|
|
214
|
+
{$match: {
|
|
215
|
+
mature: {$lte: Queue.now ()},
|
|
216
|
+
qcnt: {$gt: 0}
|
|
217
|
+
}},
|
|
218
|
+
{$group:{_id:'t', v: {$sum: '$qcnt'}}}
|
|
219
|
+
]);
|
|
220
|
+
|
|
221
|
+
cursor.toArray ((err, res) => {
|
|
222
|
+
debug ('calculating schedSize: aggregation pipeline returns %o', res);
|
|
223
|
+
if (err) return callback (err);
|
|
224
|
+
if (res.length == 0) return callback (null, 0);
|
|
225
|
+
callback (null, res[0].v);
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
//////////////////////////////////
|
|
231
|
+
// queue size of non-mature elements only
|
|
232
|
+
schedSize (callback) {
|
|
233
|
+
const cursor = this._col.aggregate ([
|
|
234
|
+
{$match: {
|
|
235
|
+
mature: {$gt: Queue.now ()},
|
|
236
|
+
reserved: {$exists: false},
|
|
237
|
+
qcnt: {$gt: 0}
|
|
238
|
+
}},
|
|
239
|
+
{$group:{_id:'t', v: {$sum: '$qcnt'}}}
|
|
240
|
+
]);
|
|
241
|
+
|
|
242
|
+
cursor.toArray ((err, res) => {
|
|
243
|
+
debug ('calculating schedSize: aggregation pipeline returns %o', res);
|
|
244
|
+
if (err) return callback (err);
|
|
245
|
+
if (res.length == 0) return callback (null, 0);
|
|
246
|
+
callback (null, res[0].v);
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
//////////////////////////////////
|
|
252
|
+
// queue size of reserved elements only
|
|
253
|
+
resvSize (callback) {
|
|
254
|
+
const cursor = this._col.aggregate ([
|
|
255
|
+
{$match: {
|
|
256
|
+
mature: {$gt: Queue.now ()},
|
|
257
|
+
reserved: {$exists: true},
|
|
258
|
+
qcnt: {$gt: 0}
|
|
259
|
+
}},
|
|
260
|
+
{$group:{_id:'t', v: {$sum: '$qcnt'}}}
|
|
261
|
+
]);
|
|
262
|
+
|
|
263
|
+
cursor.toArray ((err, res) => {
|
|
264
|
+
debug ('calculating schedSize: aggregation pipeline returns %o', res);
|
|
265
|
+
if (err) return callback (err);
|
|
266
|
+
if (res.length == 0) return callback (null, 0);
|
|
267
|
+
callback (null, res[0].v);
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
//////////////////////////////////////////////
|
|
273
|
+
// remove by id
|
|
274
|
+
remove (id, callback) {
|
|
275
|
+
const q = {
|
|
276
|
+
_id: id,
|
|
277
|
+
qcnt: { $eq: 1 }, // allow deletion ONLY if it has just one element in the intraqueue
|
|
278
|
+
reserved: {$exists: false}
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
const opts = {};
|
|
282
|
+
|
|
283
|
+
this._col.deleteOne (q, opts, (err, result) => {
|
|
284
|
+
debug ('remove: deleteOne (%j, %j) => (%j, %j)', q, opts, err, result);
|
|
285
|
+
if (err) return callback (err);
|
|
286
|
+
callback (null, result && (result.deletedCount == 1));
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
/////////////////////////////////////////
|
|
292
|
+
// get element from queue
|
|
293
|
+
next_t (callback) {
|
|
294
|
+
this._col
|
|
295
|
+
.find ()
|
|
296
|
+
.limit(1)
|
|
297
|
+
.sort ({mature:1})
|
|
298
|
+
.project ({mature:1})
|
|
299
|
+
.next ((err, result) => {
|
|
300
|
+
if (err) return callback (err);
|
|
301
|
+
callback (null, result && result.mature);
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
307
|
+
// private parts
|
|
308
|
+
|
|
309
|
+
//////////////////////////////////////////////////////////////////
|
|
310
|
+
// create needed indexes for O(1) functioning
|
|
311
|
+
ensureIndexes (cb) {
|
|
312
|
+
async.series ([
|
|
313
|
+
cb => this._col.createIndex ({mature : 1, qcnt: 1}, cb),
|
|
314
|
+
], cb);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
class Factory extends QFactory_MongoDB_defaults {
|
|
320
|
+
constructor (opts, mongo_conn) {
|
|
321
|
+
super (opts);
|
|
322
|
+
this._mongo_conn = mongo_conn;
|
|
323
|
+
this._db = mongo_conn.db();
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
queue (name, opts) {
|
|
327
|
+
var full_opts = {};
|
|
328
|
+
_.merge(full_opts, this._opts, opts);
|
|
329
|
+
return new IntraOrderedQueue (name, this, full_opts, opts);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
close (cb) {
|
|
333
|
+
super.close (() => {
|
|
334
|
+
if (this._mongo_conn) {
|
|
335
|
+
this._mongo_conn.close ();
|
|
336
|
+
this._mongo_conn = null;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
if (cb) return cb ();
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
type () {
|
|
344
|
+
return IntraOrderedQueue.Type ();
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
capabilities () {
|
|
348
|
+
return {
|
|
349
|
+
sched: true,
|
|
350
|
+
reserve: true,
|
|
351
|
+
pipeline: false,
|
|
352
|
+
tape: false,
|
|
353
|
+
remove: false
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function creator (opts, cb) {
|
|
359
|
+
var _opts = opts || {};
|
|
360
|
+
var m_url = _opts.url || 'mongodb://localhost:27017/keuss';
|
|
361
|
+
|
|
362
|
+
MongoClient.connect (m_url, { useNewUrlParser: true }, (err, cl) => {
|
|
363
|
+
if (err) return cb (err);
|
|
364
|
+
var F = new Factory (_opts, cl);
|
|
365
|
+
F.async_init (err => cb (null, F));
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
module.exports = creator;
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keuss",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.3",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"queue",
|
|
6
6
|
"persistent",
|
|
@@ -24,26 +24,26 @@
|
|
|
24
24
|
"name": "Jose Luis Martinez Juan",
|
|
25
25
|
"email": "pep.martinez@gmail.com"
|
|
26
26
|
},
|
|
27
|
-
"license": "
|
|
27
|
+
"license": "MIT",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@nodebb/mubsub": "~1.8.0",
|
|
30
|
-
"async": "~3.2.
|
|
30
|
+
"async": "~3.2.4",
|
|
31
31
|
"async-lock": "~1.3.1",
|
|
32
32
|
"debug": "~4.3.4",
|
|
33
33
|
"ioredis": "~5.0.4",
|
|
34
34
|
"lodash": "~4.17.21",
|
|
35
35
|
"mitt": "~3.0.0",
|
|
36
36
|
"mongodb": "~4.5.0",
|
|
37
|
-
"uuid": "~8.3.2"
|
|
38
|
-
"why-is-node-running": "^2.2.2"
|
|
37
|
+
"uuid": "~8.3.2"
|
|
39
38
|
},
|
|
40
39
|
"devDependencies": {
|
|
41
40
|
"chance": "~1.1.8",
|
|
42
|
-
"mocha": "~
|
|
43
|
-
"should": "~13.2.3"
|
|
41
|
+
"mocha": "~10.2.0",
|
|
42
|
+
"should": "~13.2.3",
|
|
43
|
+
"why-is-node-running": "^2.2.2"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
|
-
"test": "mocha --reporter spec --check-leaks --no-timeouts --exit test/",
|
|
47
|
-
"test-with-coverage": "nyc --reporter=html -- mocha --reporter spec --check-leaks --no-timeouts --exit test/"
|
|
46
|
+
"test": "docker compose up -d; sleep 5; mocha --reporter spec --check-leaks --no-timeouts --exit test/ ; docker compose down",
|
|
47
|
+
"test-with-coverage": "docker compose up -d; sleep 5; nyc --reporter=html -- mocha --reporter spec --check-leaks --no-timeouts --exit ; test/docker compose down"
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const async = require ('async');
|
|
2
|
+
const MQ = require ('../backends/intraorder');
|
|
3
|
+
|
|
4
|
+
// initialize factory
|
|
5
|
+
MQ ({
|
|
6
|
+
url: 'mongodb://localhost/keuss'
|
|
7
|
+
}, (err, factory) => {
|
|
8
|
+
if (err) return console.error(err);
|
|
9
|
+
|
|
10
|
+
const q = factory.queue ('test_queue', {});
|
|
11
|
+
/*
|
|
12
|
+
async.waterfall ([
|
|
13
|
+
cb => q.push ({iid: 123, elem: 1, headline: 'something something', tags: {a: 1, b: 2}}, cb),
|
|
14
|
+
(item_id, cb) => q.push ({iid: 123, elem: 2, headline: 'other other', tags: {a: 3, b: 4}}, cb),
|
|
15
|
+
(item_id, cb) => q.pop ('consumer-1', {reserve: true}, cb),
|
|
16
|
+
(item, cb) => q.ko (item, new Date().getTime () + 1500, cb),
|
|
17
|
+
(item_id, cb) => q.pop ('consumer-1', {reserve: true}, cb),
|
|
18
|
+
(item, cb) => {console.log ('%s: got %o', new Date().toISOString (), item.payload); q.ok (item, cb); },
|
|
19
|
+
(item_id, cb) => q.pop ('consumer-1', {reserve: true}, cb),
|
|
20
|
+
(item, cb) => q.ko (item, new Date().getTime () + 1500, cb),
|
|
21
|
+
(item_id, cb) => q.pop ('consumer-1', {reserve: true}, cb),
|
|
22
|
+
(item, cb) => {console.log ('%s: got %o', new Date().toISOString (), item.payload); q.ok (item, cb); },
|
|
23
|
+
(i, cb) => setTimeout (cb, 100),
|
|
24
|
+
cb => q.status (cb),
|
|
25
|
+
], (err, res) => {
|
|
26
|
+
if (err) console.error (err);
|
|
27
|
+
console.log (res)
|
|
28
|
+
factory.close ();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
async.series ([
|
|
35
|
+
cb => q.status (cb),
|
|
36
|
+
cb => q.push ({iid: 123, elem: 1, headline: 'something something', tags: {a: 1, b: 2}}, cb),
|
|
37
|
+
cb => q.status (cb),
|
|
38
|
+
cb => q.push ({iid: 123, elem: 2, headline: 'other other', tags: {a: 3, b: 4}}, cb),
|
|
39
|
+
cb => q.status (cb),
|
|
40
|
+
cb => q.pop ('consumer-1', cb),
|
|
41
|
+
cb => q.status (cb),
|
|
42
|
+
cb => q.pop ('consumer-1', cb),
|
|
43
|
+
cb => q.status (cb),
|
|
44
|
+
cb => setTimeout (cb, 100),
|
|
45
|
+
cb => q.status (cb),
|
|
46
|
+
], (err, res) => {
|
|
47
|
+
if (err) console.error (err);
|
|
48
|
+
factory.close ();
|
|
49
|
+
res.forEach ((v, i) => console.log ('%d:', i, v ));
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
});
|
|
53
|
+
|
|
@@ -77,12 +77,13 @@ function release_mq_factory (q, factory, cb) {
|
|
|
77
77
|
|
|
78
78
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
79
79
|
[
|
|
80
|
-
{label: 'Simple MongoDB', mq: require ('../backends/mongo')},
|
|
81
|
-
{label: 'Pipelined MongoDB', mq: require ('../backends/pl-mongo')},
|
|
82
|
-
{label: 'Tape MongoDB', mq: require ('../backends/ps-mongo')},
|
|
83
|
-
{label: 'Stream MongoDB', mq: require ('../backends/stream-mongo')},
|
|
84
|
-
{label: 'Redis OrderedQueue', mq: require ('../backends/redis-oq')},
|
|
85
|
-
{label: 'MongoDB SafeBucket', mq: require ('../backends/bucket-mongo-safe')}
|
|
80
|
+
// {label: 'Simple MongoDB', mq: require ('../backends/mongo')},
|
|
81
|
+
// {label: 'Pipelined MongoDB', mq: require ('../backends/pl-mongo')},
|
|
82
|
+
// {label: 'Tape MongoDB', mq: require ('../backends/ps-mongo')},
|
|
83
|
+
// {label: 'Stream MongoDB', mq: require ('../backends/stream-mongo')},
|
|
84
|
+
// {label: 'Redis OrderedQueue', mq: require ('../backends/redis-oq')},
|
|
85
|
+
// {label: 'MongoDB SafeBucket', mq: require ('../backends/bucket-mongo-safe')},
|
|
86
|
+
{label: 'Mongo IntraOrder', mq: require ('../backends/intraorder')},
|
|
86
87
|
].forEach(function (MQ_item) {
|
|
87
88
|
describe('rollback and deadletters with ' + MQ_item.label + ' queue backend', function () {
|
|
88
89
|
const MQ = MQ_item.mq;
|
package/test/backends_payload.js
CHANGED
|
@@ -10,13 +10,14 @@ var MongoClient = require ('mongodb').MongoClient;
|
|
|
10
10
|
var factory = null;
|
|
11
11
|
|
|
12
12
|
[
|
|
13
|
-
{label: 'Simple MongoDB',
|
|
14
|
-
{label: 'Pipelined MongoDB',
|
|
15
|
-
{label: 'Tape MongoDB',
|
|
16
|
-
{label: 'Stream MongoDB',
|
|
17
|
-
{label: 'Safe MongoDB Buckets',
|
|
18
|
-
{label: 'Redis List',
|
|
19
|
-
{label: 'Redis OrderedQueue',
|
|
13
|
+
{label: 'Simple MongoDB', mq: require ('../backends/mongo')},
|
|
14
|
+
{label: 'Pipelined MongoDB', mq: require ('../backends/pl-mongo')},
|
|
15
|
+
{label: 'Tape MongoDB', mq: require ('../backends/ps-mongo')},
|
|
16
|
+
{label: 'Stream MongoDB', mq: require ('../backends/stream-mongo')},
|
|
17
|
+
{label: 'Safe MongoDB Buckets', mq: require ('../backends/bucket-mongo-safe')},
|
|
18
|
+
{label: 'Redis List', mq: require ('../backends/redis-list')},
|
|
19
|
+
{label: 'Redis OrderedQueue', mq: require ('../backends/redis-oq')},
|
|
20
|
+
{label: 'Mongo IntraOrder', mq: require ('../backends/intraorder')},
|
|
20
21
|
].forEach(function (MQ_item) {
|
|
21
22
|
describe('payload aspects on ' + MQ_item.label + ' queue backend, round 1', function () {
|
|
22
23
|
var MQ = MQ_item.mq;
|