keuss 1.7.3 → 2.0.0
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/Pipeline/Queue.js +0 -1
- package/QFactory.js +11 -6
- package/Queue.js +1 -4
- package/README.md +2 -1
- package/TODO +0 -9
- package/backends/bucket-mongo-safe.js +11 -11
- package/backends/intraorder.js +13 -11
- package/backends/mongo.js +12 -9
- package/backends/pl-mongo.js +8 -5
- package/backends/postgres.js +380 -0
- package/backends/ps-mongo.js +11 -8
- package/backends/redis-list.js +8 -8
- package/backends/redis-oq.js +8 -3
- package/backends/stream-mongo.js +10 -15
- package/package.json +14 -10
- package/stats/mem.js +0 -1
- package/.github/workflows/codeql-analysis.yml +0 -72
- package/bench/all-mongo.js +0 -108
- package/bench/multi-q.js +0 -85
- package/bench/redis-oq-consumer-producer.js +0 -52
- package/bench/redis-oq-consumer.js +0 -40
- package/bench/redis-oq-producer.js +0 -43
- package/docker-compose/docker-compose.yaml +0 -18
- package/docker-compose.yaml +0 -18
- package/examples/pipelines/builder/index.js +0 -99
- package/examples/pipelines/fromRecipe/index.js +0 -127
- package/examples/pipelines/simplest/index.js +0 -38
- package/examples/pipelines/simulation-fork/index.js +0 -115
- package/examples/snippets/01-simplest-pop-push.js +0 -49
- package/examples/snippets/02-simplest-reserve-rollback-commit.js +0 -44
- package/examples/snippets/03-simplest-producer-consumer-loops.js +0 -77
- package/examples/snippets/04-bucket-mongo-safe-insert-reserve-commit.js +0 -78
- package/examples/snippets/05-insert-reserve-rollback-deadletter.js +0 -105
- package/examples/snippets/06-random-consumer-producer.js +0 -270
- package/examples/snippets/07-stream-simple.js +0 -53
- package/examples/snippets/redislabs-consumer-producer.js +0 -44
- package/examples/snippets/with-redis-stats-and-signaller-consumer-producer.js +0 -52
- package/examples/webhooks/README.md +0 -36
- package/examples/webhooks/app.js +0 -70
- package/examples/webhooks/consumer.js +0 -98
- package/examples/webhooks/index.js +0 -55
- package/examples/webhooks/package-lock.json +0 -500
- package/examples/webhooks/package.json +0 -23
- package/examples/webhooks/wh-payload.json +0 -38
- package/playground/irc.js +0 -53
- package/playground/pl-rollback.js +0 -55
- package/playground/pl1.js +0 -74
- package/playground/q1.js +0 -34
- package/playground/simple-pl.js +0 -42
- package/playground/stream-loops.js +0 -114
- package/test/backends_bucket-at-least-once.js +0 -302
- package/test/backends_deadletter.js +0 -227
- package/test/backends_payload.js +0 -542
- package/test/backends_push-pop.js +0 -170
- package/test/backends_remove.js +0 -320
- package/test/backends_reserve-commit-rollback.js +0 -1033
- package/test/intraorder.js +0 -325
- package/test/pause.js +0 -220
- package/test/pipeline-Builder.js +0 -285
- package/test/pipeline-ChoiceLink.js +0 -241
- package/test/pipeline-DirectLink.js +0 -376
- package/test/pipeline-Sink.js +0 -175
- package/test/signal.js +0 -196
- package/test/stats.js +0 -296
- package/test/stream-mongo.js +0 -166
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"contentType": "application/vnd.microsoft.card.thumbnail",
|
|
3
|
-
"content": {
|
|
4
|
-
"title": "Bender",
|
|
5
|
-
"subtitle": "tale of a robot who dared to love",
|
|
6
|
-
"text": "Bender Bending Rodríguez is a main character in the animated television series Futurama. He was created by series creators Matt Groening and David X. Cohen, and is voiced by John DiMaggio",
|
|
7
|
-
"images": [
|
|
8
|
-
{
|
|
9
|
-
"url": "https://upload.wikimedia.org/wikipedia/en/a/a6/Bender_Rodriguez.png",
|
|
10
|
-
"alt": "Bender Rodríguez"
|
|
11
|
-
}
|
|
12
|
-
],
|
|
13
|
-
"buttons": [
|
|
14
|
-
{
|
|
15
|
-
"type": "imBack",
|
|
16
|
-
"title": "Thumbs Up",
|
|
17
|
-
"image": "http://moopz.com/assets_c/2012/06/emoji-thumbs-up-150-thumb-autox125-140616.jpg",
|
|
18
|
-
"value": "I like it"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"type": "imBack",
|
|
22
|
-
"title": "Thumbs Down",
|
|
23
|
-
"image": "http://yourfaceisstupid.com/wp-content/uploads/2014/08/thumbs-down.png",
|
|
24
|
-
"value": "I don't like it"
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"type": "openUrl",
|
|
28
|
-
"title": "I feel lucky",
|
|
29
|
-
"image": "http://thumb9.shutterstock.com/photos/thumb_large/683806/148441982.jpg",
|
|
30
|
-
"value": "https://www.bing.com/images/search?q=bender&qpvt=bender&qpvt=bender&qpvt=bender&FORM=IGRE"
|
|
31
|
-
}
|
|
32
|
-
],
|
|
33
|
-
"tap": {
|
|
34
|
-
"type": "imBack",
|
|
35
|
-
"value": "Tapped it!"
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
package/playground/irc.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
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
|
-
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// mongodb: create a consumer and a producer
|
|
2
|
-
var MQ = require ('../backends/pl-mongo');
|
|
3
|
-
var DL = require ('../Pipeline/DirectLink');
|
|
4
|
-
var async = require ('async');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var factory_opts = {
|
|
8
|
-
url: 'mongodb://localhost/qeus-pl'
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
// initialize factory
|
|
12
|
-
MQ (factory_opts, function (err, factory) {
|
|
13
|
-
if (err) {
|
|
14
|
-
return console.error (err);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// factory ready, create 3 queues on default pipeline
|
|
18
|
-
var q_opts = {};
|
|
19
|
-
var q1 = factory.queue ('test_pl_r_1', q_opts);
|
|
20
|
-
var q2 = factory.queue ('test_pl_r_2', q_opts);
|
|
21
|
-
|
|
22
|
-
// tie them up, q1 -> q2
|
|
23
|
-
var pll = new DL (q1, q2);
|
|
24
|
-
|
|
25
|
-
pll.start (function (elem, done) {
|
|
26
|
-
console.log (this.name())
|
|
27
|
-
if (elem.tries < 1) {
|
|
28
|
-
console.log ('%d: nope, try %d', elem.payload.a, elem.tries)
|
|
29
|
-
done ({e: 'error, retry'});
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
console.log ('%d: alles klar, try %d', elem.payload.a, elem.tries);
|
|
33
|
-
|
|
34
|
-
const update = {
|
|
35
|
-
$set: {
|
|
36
|
-
alfa: 666*elem.tries,
|
|
37
|
-
stage: `stage-${elem.tries}`
|
|
38
|
-
},
|
|
39
|
-
$inc: {
|
|
40
|
-
'counters.alpha': 2,
|
|
41
|
-
'counters.beta': 1,
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
done (null, {update});
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
// insert elements
|
|
50
|
-
// async.timesLimit (111, 3, (n, next) => {
|
|
51
|
-
// setTimeout (() => q1.push ({a:n, b:'see it fail...'}, {}, next), 1111);
|
|
52
|
-
// });
|
|
53
|
-
|
|
54
|
-
q1.push ({a:5, b:'see it fail...'}, {}, function () {});
|
|
55
|
-
});
|
package/playground/pl1.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
// mongodb: create a consumer and a producer
|
|
2
|
-
var MQ = require ('../backends/pl-mongo');
|
|
3
|
-
var PLL = require ('../Pipeline/DirectLink');
|
|
4
|
-
var async = require ('async');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var factory_opts = {
|
|
8
|
-
url: 'mongodb://localhost/qeus'
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
// initialize factory
|
|
12
|
-
MQ (factory_opts, function (err, factory) {
|
|
13
|
-
if (err) {
|
|
14
|
-
return console.error (err);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// factory ready, create 3 queues on default pipeline
|
|
18
|
-
var q_opts = {};
|
|
19
|
-
var q1 = factory.queue ('test_pl_1', q_opts);
|
|
20
|
-
var q2 = factory.queue ('test_pl_2', q_opts);
|
|
21
|
-
var q3 = factory.queue ('test_pl_3', q_opts);
|
|
22
|
-
|
|
23
|
-
// tie them up, q1 -> q2 -> q3 -> q1
|
|
24
|
-
var pll1 = new PLL (q1, q2, {delay: 1});
|
|
25
|
-
var pll2 = new PLL (q2, q3);
|
|
26
|
-
var pll3 = new PLL (q3, q1);
|
|
27
|
-
|
|
28
|
-
pll1.start (function (elem, done) {
|
|
29
|
-
var pl = elem.payload;
|
|
30
|
-
|
|
31
|
-
if (!pl.processed_1) {
|
|
32
|
-
pl.processed_1=1
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
pl.processed_1++
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
console.log ('%s: tick', pll1.name ());
|
|
39
|
-
done();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
pll2.start (function (elem, done) {
|
|
43
|
-
var pl = elem.payload;
|
|
44
|
-
|
|
45
|
-
if (!pl.processed_2) {
|
|
46
|
-
pl.processed_2=1
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
pl.processed_2++
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
console.log ('%s: tick', pll2.name ());
|
|
53
|
-
done();
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
pll3.start (function (elem, done) {
|
|
57
|
-
var pl = elem.payload;
|
|
58
|
-
|
|
59
|
-
if (!pl.processed_3) {
|
|
60
|
-
pl.processed_3=1
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
pl.processed_3++
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
console.log ('%s: tick', pll3.name ());
|
|
67
|
-
done ();
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
// insert elements
|
|
71
|
-
async.timesLimit (111, 3, function (n, next) {
|
|
72
|
-
q1.push ({a:n, b:'see it spin...'}, {}, next);
|
|
73
|
-
});
|
|
74
|
-
});
|
package/playground/q1.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// mongodb: create a consumer and a producer
|
|
2
|
-
var MQ = require ('../backends/pl-mongo');
|
|
3
|
-
|
|
4
|
-
var factory_opts = {
|
|
5
|
-
url: 'mongodb://localhost/qeus'
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
// initialize factory
|
|
9
|
-
MQ (factory_opts, function (err, factory) {
|
|
10
|
-
if (err) {
|
|
11
|
-
return console.error (err);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// factory ready, create one queue
|
|
15
|
-
var q_opts = {};
|
|
16
|
-
var q = factory.queue ('test_queue', q_opts);
|
|
17
|
-
|
|
18
|
-
// insert element
|
|
19
|
-
q.push ({a:1, b:'666'}, {delay: 3}, function (err, res) {
|
|
20
|
-
if (err) {
|
|
21
|
-
return console.error (err);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// element inserted at this point. pop it again
|
|
25
|
-
var pop_opts = {};
|
|
26
|
-
q.pop ('consumer-one', pop_opts, function (err, res) {
|
|
27
|
-
if (err) {
|
|
28
|
-
return console.error (err);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
console.log ('got this: ', res);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
});
|
package/playground/simple-pl.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
var MQ = require ('../backends/pl-mongo');
|
|
2
|
-
var PLL = require ('../Pipeline/DirectLink');
|
|
3
|
-
var async = require ('async');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var factory_opts = {
|
|
7
|
-
url: 'mongodb://localhost/qeus'
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
// initialize factory
|
|
11
|
-
MQ (factory_opts, function (err, factory) {
|
|
12
|
-
if (err) {
|
|
13
|
-
return console.error (err);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// factory ready, create 2 queues on default pipeline
|
|
17
|
-
var q_opts = {};
|
|
18
|
-
var q1 = factory.queue ('test_pl_1', q_opts);
|
|
19
|
-
var q2 = factory.queue ('test_pl_2', q_opts);
|
|
20
|
-
|
|
21
|
-
// tie them up, q1 -> q2
|
|
22
|
-
var pll = new PLL (q1, q2);
|
|
23
|
-
|
|
24
|
-
pll.start (function (elem, done) {
|
|
25
|
-
var pl = elem.payload;
|
|
26
|
-
pl.pll_processed = true;
|
|
27
|
-
done();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
// insert elements in the entry queue
|
|
31
|
-
async.timesLimit (111, 3, function (n, next) {
|
|
32
|
-
q1.push ({a:n, b:'see it spin...'}, {}, next);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
async.timesLimit (111, 3, function (n, next) {
|
|
36
|
-
q2.pop ('exit', {}, function (err, res) {
|
|
37
|
-
console.log ('end point get', res);
|
|
38
|
-
next ();
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
*
|
|
3
|
-
* very simple example of stream-mongo: one element pushed, consumed three times
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const async = require ('async');
|
|
8
|
-
const _ = require ('lodash');
|
|
9
|
-
const MQ = require ('../backends/stream-mongo');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const group_cardinality = 3;
|
|
13
|
-
const mesgs = 1000000;
|
|
14
|
-
|
|
15
|
-
const stats = {
|
|
16
|
-
consumer: {
|
|
17
|
-
last: 0,
|
|
18
|
-
total: 0
|
|
19
|
-
},
|
|
20
|
-
producer: {
|
|
21
|
-
last: 0,
|
|
22
|
-
total: 0
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function do_times (cnt, fn, done) {
|
|
27
|
-
if (!cnt) {
|
|
28
|
-
console.log ('loop done')
|
|
29
|
-
return done(null, 0);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
fn (cnt, err => {
|
|
33
|
-
if (err) return done (err, cnt);
|
|
34
|
-
do_times (cnt-1, fn, done);
|
|
35
|
-
})
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
function payload (n) {
|
|
40
|
-
return {elem: n, headline: 'something something', tags: {a: n, b: 2*n}}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
function headers (n) {
|
|
45
|
-
return {cnt: n, h1: 'something something', h2: false}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
function producer_looper (q, id) {
|
|
50
|
-
console.log (`creating producer looper ${id}`);
|
|
51
|
-
return (n, cb) => {
|
|
52
|
-
q.push (payload (n), {hdrs: headers(n)}, err => {
|
|
53
|
-
// console.log ('[%s] push #%d', id, n);
|
|
54
|
-
stats.producer.total++;
|
|
55
|
-
cb (err);
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
function consumer_looper (q, id) {
|
|
62
|
-
console.log (`creating consumer looper ${id}`);
|
|
63
|
-
return (n, cb) => {
|
|
64
|
-
q.pop (id, err => {
|
|
65
|
-
// console.log ('[%s] pop #%d', id, n);
|
|
66
|
-
stats.consumer.total++
|
|
67
|
-
cb (err);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
// initialize factory
|
|
74
|
-
MQ ({
|
|
75
|
-
url: 'mongodb://localhost/keuss_test_stream'
|
|
76
|
-
}, (err, factory) => {
|
|
77
|
-
if (err) return console.error(err);
|
|
78
|
-
|
|
79
|
-
const groups = _.range (1, group_cardinality + 1).map (i => `G${i}`).join (',');
|
|
80
|
-
console.log('groups: ', groups);
|
|
81
|
-
|
|
82
|
-
// create queues and clients
|
|
83
|
-
const queues = {};
|
|
84
|
-
queues['qp'] = factory.queue ('test_stream', {groups});
|
|
85
|
-
|
|
86
|
-
for (let i = 1; i <= group_cardinality; i++) {
|
|
87
|
-
queues[`qc${i}`] = factory.queue ('test_stream', {group: `G${i}`});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
console.log (`created queues (one producer, ${group_cardinality} consumers)`);
|
|
91
|
-
|
|
92
|
-
// create tasks
|
|
93
|
-
const tasks = [];
|
|
94
|
-
tasks.push (cb => do_times (mesgs, producer_looper (queues['qp'], 'p0'), cb));
|
|
95
|
-
|
|
96
|
-
for (let t = 1; t <= group_cardinality; t++) {
|
|
97
|
-
tasks.push (cb => do_times (mesgs, consumer_looper (queues[`qc${t}`], `c${t}`), cb),)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
console.log (`created tasks (one producer, ${group_cardinality} consumers)`);
|
|
101
|
-
|
|
102
|
-
async.parallel (tasks, err => {
|
|
103
|
-
factory.close ();
|
|
104
|
-
if (err) console.error (err);
|
|
105
|
-
console.log ('done');
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
setInterval (() => {
|
|
109
|
-
console.log (`produced ${stats.producer.total - stats.producer.last} msg/s, consumed ${stats.consumer.total - stats.consumer.last} msg/s`);
|
|
110
|
-
stats.producer.last = stats.producer.total;
|
|
111
|
-
stats.consumer.last = stats.consumer.total
|
|
112
|
-
}, 1000);
|
|
113
|
-
});
|
|
114
|
-
|