keuss 1.6.4 → 1.6.8
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/.nyc_output/ad035de4-a3d3-451b-b2ad-402e8ed517b8.json +1 -0
- package/.nyc_output/{06313f3e-1553-402b-bdc2-3a7a639cd559.json → c8683d6c-e7e6-496b-ab0d-1ff730837d08.json} +0 -0
- package/.nyc_output/processinfo/ad035de4-a3d3-451b-b2ad-402e8ed517b8.json +1 -0
- package/.nyc_output/processinfo/c8683d6c-e7e6-496b-ab0d-1ff730837d08.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/Pipeline/Queue.js +24 -1
- package/Queue.js +26 -10
- package/TODO +0 -7
- package/backends/bucket-mongo-safe.js +39 -3
- package/backends/mongo.js +23 -2
- package/backends/pl-mongo.js +2 -1
- package/backends/ps-mongo.js +31 -2
- package/backends/redis-oq.js +12 -1
- package/coverage/index.html +43 -43
- package/coverage/keuss/Pipeline/BaseLink.js.html +18 -18
- package/coverage/keuss/Pipeline/Builder.js.html +1 -1
- package/coverage/keuss/Pipeline/ChoiceLink.js.html +1 -1
- package/coverage/keuss/Pipeline/DirectLink.js.html +1 -1
- package/coverage/keuss/Pipeline/Pipeline.js.html +15 -15
- package/coverage/keuss/Pipeline/Queue.js.html +124 -55
- package/coverage/keuss/Pipeline/Sink.js.html +1 -1
- package/coverage/keuss/Pipeline/index.html +18 -18
- package/coverage/keuss/QFactory-MongoDB-defaults.js.html +6 -6
- package/coverage/keuss/QFactory.js.html +28 -28
- package/coverage/keuss/Queue.js.html +232 -181
- package/coverage/keuss/Signal.js.html +28 -28
- package/coverage/keuss/Stats.js.html +4 -4
- package/coverage/keuss/backends/bucket-mongo-safe.js.html +476 -314
- package/coverage/keuss/backends/bucket-mongo.js.html +134 -86
- package/coverage/keuss/backends/index.html +69 -69
- package/coverage/keuss/backends/mongo.js.html +137 -74
- package/coverage/keuss/backends/pl-mongo.js.html +54 -54
- package/coverage/keuss/backends/ps-mongo.js.html +164 -80
- package/coverage/keuss/backends/redis-list.js.html +39 -36
- package/coverage/keuss/backends/redis-oq.js.html +27 -27
- package/coverage/keuss/index.html +18 -18
- package/coverage/keuss/signal/index.html +1 -1
- package/coverage/keuss/signal/local.js.html +17 -17
- package/coverage/keuss/signal/mongo-capped.js.html +1 -1
- package/coverage/keuss/signal/redis-pubsub.js.html +12 -12
- package/coverage/keuss/stats/index.html +10 -10
- package/coverage/keuss/stats/mem.js.html +36 -30
- package/coverage/keuss/stats/mongo.js.html +8 -8
- package/coverage/keuss/stats/redis.js.html +17 -17
- package/coverage/keuss/utils/RedisConn.js.html +1 -1
- package/coverage/keuss/utils/RedisOrderedQueue.js.html +36 -33
- package/coverage/keuss/utils/index.html +5 -5
- package/docusaurus/docs/api/queue.md +24 -1
- package/docusaurus/docs/changelog.md +11 -0
- package/docusaurus/docs/concepts.md +13 -9
- package/docusaurus/package-lock.json +4422 -10244
- package/docusaurus/package.json +6 -6
- package/docusaurus/yarn.lock +8864 -0
- package/package.json +11 -11
- package/stats/mem.js +3 -1
- package/test/backends_bucket-at-least-once.js +13 -13
- package/test/backends_remove.js +299 -0
- package/test/backends_reserve-commit-rollback.js +165 -151
- package/utils/RedisOrderedQueue.js +46 -3
- package/.nyc_output/a06aa990-295d-4428-872d-ba9fa06afd1f.json +0 -1
- package/.nyc_output/processinfo/06313f3e-1553-402b-bdc2-3a7a639cd559.json +0 -1
- package/.nyc_output/processinfo/a06aa990-295d-4428-872d-ba9fa06afd1f.json +0 -1
|
@@ -56,7 +56,10 @@ var factory = null;
|
|
|
56
56
|
if (err) return done (err);
|
|
57
57
|
results.should.eql([{
|
|
58
58
|
get: 0,
|
|
59
|
-
put: 0
|
|
59
|
+
put: 0,
|
|
60
|
+
reserve: 0,
|
|
61
|
+
commit: 0,
|
|
62
|
+
rollback: 0
|
|
60
63
|
}, 0, 0, 0, null]);
|
|
61
64
|
done();
|
|
62
65
|
});
|
|
@@ -66,82 +69,66 @@ var factory = null;
|
|
|
66
69
|
var q = factory.queue('test_queue_2');
|
|
67
70
|
|
|
68
71
|
async.series([
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}, cb)
|
|
74
|
-
},
|
|
75
|
-
function (cb) {
|
|
76
|
-
q.push({
|
|
77
|
-
elem: 2,
|
|
78
|
-
pl: 'twetrwte'
|
|
79
|
-
}, cb)
|
|
80
|
-
},
|
|
81
|
-
function (cb) {
|
|
82
|
-
q.size(function (err, size) {
|
|
72
|
+
cb => q.push({elem: 1, pl: 'twetrwte'}, cb),
|
|
73
|
+
cb => q.push({elem: 2, pl: 'twetrwte'}, cb),
|
|
74
|
+
cb => {
|
|
75
|
+
q.size ((err, size) => {
|
|
83
76
|
size.should.equal(2);
|
|
84
77
|
cb();
|
|
85
78
|
})
|
|
86
79
|
},
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
cb();
|
|
118
|
-
})
|
|
119
|
-
},
|
|
120
|
-
function (cb) {
|
|
121
|
-
q.pop('c2', cb)
|
|
122
|
-
},
|
|
80
|
+
cb => q.stats((err, res) => {
|
|
81
|
+
res.should.eql({
|
|
82
|
+
get: 0,
|
|
83
|
+
put: 2,
|
|
84
|
+
reserve: 0,
|
|
85
|
+
commit: 0,
|
|
86
|
+
rollback: 0
|
|
87
|
+
});
|
|
88
|
+
cb();
|
|
89
|
+
}),
|
|
90
|
+
cb=> q.next_t((err, res) => {
|
|
91
|
+
res.getTime().should.be.approximately(new Date().getTime(), 500);
|
|
92
|
+
cb();
|
|
93
|
+
}),
|
|
94
|
+
cb => q.pop('c1', cb),
|
|
95
|
+
cb => q.size((err, size) => {
|
|
96
|
+
size.should.equal(1);
|
|
97
|
+
cb();
|
|
98
|
+
}),
|
|
99
|
+
cb => q.stats((err, res) => {
|
|
100
|
+
res.should.eql({
|
|
101
|
+
get: 1,
|
|
102
|
+
put: 2,
|
|
103
|
+
reserve: 0,
|
|
104
|
+
commit: 0,
|
|
105
|
+
rollback: 0
|
|
106
|
+
});
|
|
107
|
+
cb();
|
|
108
|
+
}),
|
|
109
|
+
cb => q.pop('c2', cb),
|
|
123
110
|
function (cb) {
|
|
124
111
|
q.size(function (err, size) {
|
|
125
112
|
size.should.equal(0);
|
|
126
113
|
cb();
|
|
127
114
|
})
|
|
128
115
|
},
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
],
|
|
116
|
+
cb => setTimeout (cb, 1000),
|
|
117
|
+
cb => q.stats((err, res) => {
|
|
118
|
+
res.should.eql({
|
|
119
|
+
get: 2,
|
|
120
|
+
put: 2,
|
|
121
|
+
reserve: 0,
|
|
122
|
+
commit: 0,
|
|
123
|
+
rollback: 0
|
|
124
|
+
});
|
|
125
|
+
cb();
|
|
126
|
+
}),
|
|
127
|
+
cb => q.next_t((err, res) => {
|
|
128
|
+
should.equal(res, null);
|
|
129
|
+
cb();
|
|
130
|
+
})
|
|
131
|
+
], (err, results) => {
|
|
145
132
|
done();
|
|
146
133
|
});
|
|
147
134
|
});
|
|
@@ -181,7 +168,10 @@ var factory = null;
|
|
|
181
168
|
q.stats(function (err, res) {
|
|
182
169
|
res.should.eql({
|
|
183
170
|
get: 0,
|
|
184
|
-
put: 2
|
|
171
|
+
put: 2,
|
|
172
|
+
reserve: 0,
|
|
173
|
+
commit: 0,
|
|
174
|
+
rollback: 0
|
|
185
175
|
});
|
|
186
176
|
cb();
|
|
187
177
|
})
|
|
@@ -211,10 +201,13 @@ var factory = null;
|
|
|
211
201
|
q.stats(function (err, res) {
|
|
212
202
|
res.should.eql({
|
|
213
203
|
get: 1,
|
|
214
|
-
put: 2
|
|
204
|
+
put: 2,
|
|
205
|
+
reserve: 0,
|
|
206
|
+
commit: 0,
|
|
207
|
+
rollback: 0
|
|
215
208
|
});
|
|
216
209
|
cb();
|
|
217
|
-
})
|
|
210
|
+
});
|
|
218
211
|
},
|
|
219
212
|
function (cb) {
|
|
220
213
|
q.next_t(function (err, res) {
|
|
@@ -241,7 +234,10 @@ var factory = null;
|
|
|
241
234
|
q.stats(function (err, res) {
|
|
242
235
|
res.should.eql({
|
|
243
236
|
get: 2,
|
|
244
|
-
put: 2
|
|
237
|
+
put: 2,
|
|
238
|
+
reserve: 0,
|
|
239
|
+
commit: 0,
|
|
240
|
+
rollback: 0
|
|
245
241
|
});
|
|
246
242
|
cb();
|
|
247
243
|
})
|
|
@@ -250,7 +246,7 @@ var factory = null;
|
|
|
250
246
|
q.next_t(function (err, res) {
|
|
251
247
|
should.equal(res, null);
|
|
252
248
|
cb();
|
|
253
|
-
})
|
|
249
|
+
});
|
|
254
250
|
}
|
|
255
251
|
], function (err, results) {
|
|
256
252
|
done();
|
|
@@ -292,7 +288,10 @@ var factory = null;
|
|
|
292
288
|
q.stats(function (err, res) {
|
|
293
289
|
res.should.eql({
|
|
294
290
|
get: 0,
|
|
295
|
-
put: 2
|
|
291
|
+
put: 2,
|
|
292
|
+
reserve: 0,
|
|
293
|
+
commit: 0,
|
|
294
|
+
rollback: 0
|
|
296
295
|
});
|
|
297
296
|
cb();
|
|
298
297
|
})
|
|
@@ -315,7 +314,10 @@ var factory = null;
|
|
|
315
314
|
q.stats(function (err, res) {
|
|
316
315
|
res.should.eql({
|
|
317
316
|
get: 0,
|
|
318
|
-
put: 2
|
|
317
|
+
put: 2,
|
|
318
|
+
reserve: 0,
|
|
319
|
+
commit: 0,
|
|
320
|
+
rollback: 0
|
|
319
321
|
});
|
|
320
322
|
cb();
|
|
321
323
|
})
|
|
@@ -338,7 +340,10 @@ var factory = null;
|
|
|
338
340
|
q.stats(function (err, res) {
|
|
339
341
|
res.should.eql({
|
|
340
342
|
get: 0,
|
|
341
|
-
put: 2
|
|
343
|
+
put: 2,
|
|
344
|
+
reserve: 0,
|
|
345
|
+
commit: 0,
|
|
346
|
+
rollback: 0
|
|
342
347
|
});
|
|
343
348
|
cb();
|
|
344
349
|
})
|
|
@@ -375,7 +380,10 @@ var factory = null;
|
|
|
375
380
|
q.stats(function (err, res) {
|
|
376
381
|
res.should.eql({
|
|
377
382
|
get: 2,
|
|
378
|
-
put: 2
|
|
383
|
+
put: 2,
|
|
384
|
+
reserve: 0,
|
|
385
|
+
commit: 0,
|
|
386
|
+
rollback: 0
|
|
379
387
|
});
|
|
380
388
|
cb();
|
|
381
389
|
})
|
|
@@ -452,7 +460,10 @@ var factory = null;
|
|
|
452
460
|
q.stats(function (err, res) {
|
|
453
461
|
res.should.eql({
|
|
454
462
|
get: 2,
|
|
455
|
-
put: 2
|
|
463
|
+
put: 2,
|
|
464
|
+
reserve: 0,
|
|
465
|
+
commit: 0,
|
|
466
|
+
rollback: 0
|
|
456
467
|
});
|
|
457
468
|
cb();
|
|
458
469
|
})
|
|
@@ -505,7 +516,10 @@ var factory = null;
|
|
|
505
516
|
q.stats(function (err, res) {
|
|
506
517
|
res.should.eql({
|
|
507
518
|
get: 0,
|
|
508
|
-
put: 3
|
|
519
|
+
put: 3,
|
|
520
|
+
reserve: 0,
|
|
521
|
+
commit: 0,
|
|
522
|
+
rollback: 0
|
|
509
523
|
});
|
|
510
524
|
cb();
|
|
511
525
|
})
|
|
@@ -559,7 +573,10 @@ var factory = null;
|
|
|
559
573
|
q.stats(function (err, res) {
|
|
560
574
|
res.should.eql({
|
|
561
575
|
get: 3,
|
|
562
|
-
put: 3
|
|
576
|
+
put: 3,
|
|
577
|
+
reserve: 0,
|
|
578
|
+
commit: 0,
|
|
579
|
+
rollback: 0
|
|
563
580
|
});
|
|
564
581
|
cb();
|
|
565
582
|
})
|
|
@@ -574,78 +591,53 @@ var factory = null;
|
|
|
574
591
|
var id = null;
|
|
575
592
|
|
|
576
593
|
async.series([
|
|
577
|
-
|
|
578
|
-
|
|
594
|
+
cb => q.push({elem: 1, pl: 'twetrwte'}, cb),
|
|
595
|
+
cb => q.size((err, size) => {
|
|
596
|
+
size.should.equal(1);
|
|
597
|
+
cb();
|
|
598
|
+
}),
|
|
599
|
+
cb => q.next_t((err, res) => {
|
|
600
|
+
res.getTime().should.be.approximately(new Date().getTime(), 500);
|
|
601
|
+
cb();
|
|
602
|
+
}),
|
|
603
|
+
cb => q.reserve((err, res) => {
|
|
604
|
+
id = res._id;
|
|
605
|
+
res.payload.should.eql({
|
|
579
606
|
elem: 1,
|
|
580
607
|
pl: 'twetrwte'
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
},
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
size.should.equal(1);
|
|
615
|
-
cb();
|
|
616
|
-
})
|
|
617
|
-
},
|
|
618
|
-
function (cb) {
|
|
619
|
-
q.next_t(function (err, res) {
|
|
620
|
-
res.getTime().should.be.approximately(new Date().getTime() + 120000, 500);
|
|
621
|
-
cb();
|
|
622
|
-
})
|
|
623
|
-
},
|
|
624
|
-
function (cb) {
|
|
625
|
-
q.commit(id, function (err, res) {
|
|
626
|
-
res.should.equal(true);
|
|
627
|
-
cb();
|
|
628
|
-
})
|
|
629
|
-
},
|
|
630
|
-
function (cb) {
|
|
631
|
-
q.size(function (err, size) {
|
|
632
|
-
size.should.equal(0);
|
|
633
|
-
cb();
|
|
634
|
-
})
|
|
635
|
-
},
|
|
636
|
-
function (cb) {
|
|
637
|
-
q.totalSize(function (err, size) {
|
|
638
|
-
size.should.equal(0);
|
|
639
|
-
cb();
|
|
640
|
-
})
|
|
641
|
-
},
|
|
642
|
-
function (cb) {
|
|
643
|
-
q.next_t(function (err, res) {
|
|
644
|
-
should.equal(res, null);
|
|
645
|
-
cb();
|
|
646
|
-
})
|
|
647
|
-
}
|
|
648
|
-
], function (err, results) {
|
|
608
|
+
});
|
|
609
|
+
res.tries.should.equal(0);
|
|
610
|
+
cb();
|
|
611
|
+
}),
|
|
612
|
+
cb => q.size((err, size) => {
|
|
613
|
+
size.should.equal(0);
|
|
614
|
+
cb();
|
|
615
|
+
}),
|
|
616
|
+
cb => q.totalSize((err, size) => {
|
|
617
|
+
size.should.equal(1);
|
|
618
|
+
cb();
|
|
619
|
+
}),
|
|
620
|
+
cb => q.next_t((err, res) => {
|
|
621
|
+
res.getTime().should.be.approximately(new Date().getTime() + 120000, 500);
|
|
622
|
+
cb();
|
|
623
|
+
}),
|
|
624
|
+
cb => q.commit(id, (err, res) => {
|
|
625
|
+
res.should.equal(true);
|
|
626
|
+
cb();
|
|
627
|
+
}),
|
|
628
|
+
cb => q.size((err, size) => {
|
|
629
|
+
size.should.equal(0);
|
|
630
|
+
cb();
|
|
631
|
+
}),
|
|
632
|
+
cb => q.totalSize((err, size) => {
|
|
633
|
+
size.should.equal(0);
|
|
634
|
+
cb();
|
|
635
|
+
}),
|
|
636
|
+
cb => q.next_t((err, res) => {
|
|
637
|
+
should.equal(res, null);
|
|
638
|
+
cb();
|
|
639
|
+
}),
|
|
640
|
+
], (err, results) => {
|
|
649
641
|
done();
|
|
650
642
|
});
|
|
651
643
|
});
|
|
@@ -778,7 +770,7 @@ var factory = null;
|
|
|
778
770
|
should.equal(res, null);
|
|
779
771
|
cb();
|
|
780
772
|
})
|
|
781
|
-
}
|
|
773
|
+
},
|
|
782
774
|
], function (err, results) {
|
|
783
775
|
done();
|
|
784
776
|
});
|
|
@@ -849,7 +841,18 @@ var factory = null;
|
|
|
849
841
|
should.equal(res, null);
|
|
850
842
|
cb();
|
|
851
843
|
})
|
|
852
|
-
}
|
|
844
|
+
},
|
|
845
|
+
cb => setTimeout (cb, 1000),
|
|
846
|
+
cb => q.stats((err, res) => {
|
|
847
|
+
res.should.eql({
|
|
848
|
+
get: 0,
|
|
849
|
+
put: 1,
|
|
850
|
+
reserve: 1,
|
|
851
|
+
commit: 1,
|
|
852
|
+
rollback: 0
|
|
853
|
+
});
|
|
854
|
+
cb();
|
|
855
|
+
}),
|
|
853
856
|
], function (err, results) {
|
|
854
857
|
done();
|
|
855
858
|
});
|
|
@@ -976,6 +979,17 @@ var factory = null;
|
|
|
976
979
|
cb (null, res);
|
|
977
980
|
}),
|
|
978
981
|
cb => q.ok (state.reserved_obj, cb),
|
|
982
|
+
cb => setTimeout (cb, 1000),
|
|
983
|
+
cb => q.stats((err, res) => {
|
|
984
|
+
res.should.eql({
|
|
985
|
+
get: 0,
|
|
986
|
+
put: 1,
|
|
987
|
+
reserve: 3,
|
|
988
|
+
commit: 1,
|
|
989
|
+
rollback: 2
|
|
990
|
+
});
|
|
991
|
+
cb();
|
|
992
|
+
}),
|
|
979
993
|
], done);
|
|
980
994
|
});
|
|
981
995
|
|
|
@@ -11,7 +11,8 @@ const _s_lua_code_push = `
|
|
|
11
11
|
redis.call ('HSET', 'keuss:q:ordered_queue:hash:' .. KEYS[1], ARGV[1], ARGV[3])
|
|
12
12
|
|
|
13
13
|
-- insert id+mature in index
|
|
14
|
-
|
|
14
|
+
redis.call ('ZADD', 'keuss:q:ordered_queue:index:' .. KEYS[1], ARGV[2], ARGV[1])
|
|
15
|
+
return ARGV[1]
|
|
15
16
|
`;
|
|
16
17
|
|
|
17
18
|
const _s_lua_code_pop = `
|
|
@@ -86,7 +87,7 @@ const _s_lua_code_commit = `
|
|
|
86
87
|
local id = ARGV[1]
|
|
87
88
|
local val = redis.call ('HGET', 'keuss:q:ordered_queue:hash:' .. KEYS[1], id)
|
|
88
89
|
|
|
89
|
-
if (val
|
|
90
|
+
if (not(val)) then
|
|
90
91
|
return nil
|
|
91
92
|
end
|
|
92
93
|
|
|
@@ -113,7 +114,7 @@ const _s_lua_code_rollback = `
|
|
|
113
114
|
local id = ARGV[1]
|
|
114
115
|
local val = redis.call ('HGET', 'keuss:q:ordered_queue:hash:' .. KEYS[1], id)
|
|
115
116
|
|
|
116
|
-
if (val
|
|
117
|
+
if (not(val)) then
|
|
117
118
|
return nil
|
|
118
119
|
end
|
|
119
120
|
|
|
@@ -135,6 +136,31 @@ const _s_lua_code_rollback = `
|
|
|
135
136
|
return id
|
|
136
137
|
`;
|
|
137
138
|
|
|
139
|
+
const _s_lua_code_remove = `
|
|
140
|
+
-- qname in KEYS[1]
|
|
141
|
+
-- id in ARGV[1]
|
|
142
|
+
|
|
143
|
+
local id = ARGV[1]
|
|
144
|
+
local val = redis.call ('HGET', 'keuss:q:ordered_queue:hash:' .. KEYS[1], id)
|
|
145
|
+
|
|
146
|
+
if (not (val)) then
|
|
147
|
+
return nil
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
-- check if it was reserved
|
|
151
|
+
local obj_val = cjson.decode (val)
|
|
152
|
+
|
|
153
|
+
if (obj_val.reserved) then
|
|
154
|
+
-- it is reserved
|
|
155
|
+
return nil
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
-- delete from index, hash
|
|
159
|
+
redis.call ('ZREM', 'keuss:q:ordered_queue:index:' .. KEYS[1], id)
|
|
160
|
+
redis.call ('HDEL', 'keuss:q:ordered_queue:hash:' .. KEYS[1], id)
|
|
161
|
+
|
|
162
|
+
return id
|
|
163
|
+
`;
|
|
138
164
|
|
|
139
165
|
|
|
140
166
|
class RedisOrderedQueue {
|
|
@@ -164,6 +190,7 @@ class RedisOrderedQueue {
|
|
|
164
190
|
this._rediscl.roq_push (this._name, pl._id, pl.mature, JSON.stringify (pl), done);
|
|
165
191
|
}
|
|
166
192
|
|
|
193
|
+
|
|
167
194
|
//////////////////////////////////
|
|
168
195
|
pop (done) {
|
|
169
196
|
//////////////////////////////////
|
|
@@ -184,6 +211,7 @@ class RedisOrderedQueue {
|
|
|
184
211
|
});
|
|
185
212
|
}
|
|
186
213
|
|
|
214
|
+
|
|
187
215
|
//////////////////////////////////
|
|
188
216
|
reserve (incr, done) {
|
|
189
217
|
//////////////////////////////////
|
|
@@ -204,18 +232,21 @@ class RedisOrderedQueue {
|
|
|
204
232
|
});
|
|
205
233
|
}
|
|
206
234
|
|
|
235
|
+
|
|
207
236
|
//////////////////////////////////
|
|
208
237
|
commit (id, done) {
|
|
209
238
|
//////////////////////////////////
|
|
210
239
|
this._rediscl.roq_commit (this._name, id, done);
|
|
211
240
|
}
|
|
212
241
|
|
|
242
|
+
|
|
213
243
|
//////////////////////////////////
|
|
214
244
|
rollback (id, next_t, done) {
|
|
215
245
|
//////////////////////////////////
|
|
216
246
|
this._rediscl.roq_rollback (this._name, id, next_t || (new Date().getTime ()), done);
|
|
217
247
|
}
|
|
218
248
|
|
|
249
|
+
|
|
219
250
|
//////////////////////////////////
|
|
220
251
|
// queue size including non-mature elements
|
|
221
252
|
totalSize (callback) {
|
|
@@ -223,6 +254,7 @@ class RedisOrderedQueue {
|
|
|
223
254
|
this._rediscl.zcard ('keuss:q:ordered_queue:index:' + this._name, callback);
|
|
224
255
|
}
|
|
225
256
|
|
|
257
|
+
|
|
226
258
|
//////////////////////////////////
|
|
227
259
|
// queue size NOT including non-mature elements
|
|
228
260
|
size (callback) {
|
|
@@ -230,6 +262,7 @@ class RedisOrderedQueue {
|
|
|
230
262
|
this._rediscl.zcount ('keuss:q:ordered_queue:index:' + this._name, '-inf', new Date().getTime(), callback);
|
|
231
263
|
}
|
|
232
264
|
|
|
265
|
+
|
|
233
266
|
//////////////////////////////////
|
|
234
267
|
// queue size of non-mature elements only
|
|
235
268
|
schedSize (callback) {
|
|
@@ -237,12 +270,20 @@ class RedisOrderedQueue {
|
|
|
237
270
|
this._rediscl.zcount ('keuss:q:ordered_queue:index:' + this._name, new Date().getTime(), '+inf', callback);
|
|
238
271
|
}
|
|
239
272
|
|
|
273
|
+
|
|
240
274
|
//////////////////////////////////
|
|
241
275
|
// get first
|
|
242
276
|
peek (callback) {
|
|
243
277
|
//////////////////////////////////
|
|
244
278
|
this._rediscl.zrange ('keuss:q:ordered_queue:index:' + this._name, 0, 0, 'WITHSCORES', callback);
|
|
245
279
|
}
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
//////////////////////////////////
|
|
283
|
+
remove (id, done) {
|
|
284
|
+
//////////////////////////////////
|
|
285
|
+
this._rediscl.roq_remove (this._name, id, done);
|
|
286
|
+
}
|
|
246
287
|
}
|
|
247
288
|
|
|
248
289
|
|
|
@@ -255,8 +296,10 @@ class Factory {
|
|
|
255
296
|
this._rediscl.defineCommand('roq_reserve', {numberOfKeys: 1, lua: _s_lua_code_reserve});
|
|
256
297
|
this._rediscl.defineCommand('roq_commit', {numberOfKeys: 1, lua: _s_lua_code_commit});
|
|
257
298
|
this._rediscl.defineCommand('roq_rollback', {numberOfKeys: 1, lua: _s_lua_code_rollback});
|
|
299
|
+
this._rediscl.defineCommand('roq_remove', {numberOfKeys: 1, lua: _s_lua_code_remove});
|
|
258
300
|
}
|
|
259
301
|
|
|
302
|
+
|
|
260
303
|
roq (name) {
|
|
261
304
|
return new RedisOrderedQueue (name, this);
|
|
262
305
|
}
|