keuss 1.7.4 → 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 +12 -8
- 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
package/backends/ps-mongo.js
CHANGED
|
@@ -16,9 +16,7 @@ class PersistentMongoQueue extends Queue {
|
|
|
16
16
|
|
|
17
17
|
if (!this._opts.ttl) this._opts.ttl = 3600;
|
|
18
18
|
|
|
19
|
-
this._factory = factory;
|
|
20
19
|
this._col = factory._db.collection (name);
|
|
21
|
-
this.ensureIndexes (function (err) {});
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
|
|
@@ -37,7 +35,6 @@ class PersistentMongoQueue extends Queue {
|
|
|
37
35
|
insert (entry, callback) {
|
|
38
36
|
this._col.insertOne (entry, {}, (err, result) => {
|
|
39
37
|
if (err) return callback (err);
|
|
40
|
-
// TODO result.insertedCount must be 1
|
|
41
38
|
callback (null, result.insertedId);
|
|
42
39
|
});
|
|
43
40
|
}
|
|
@@ -273,10 +270,10 @@ class PersistentMongoQueue extends Queue {
|
|
|
273
270
|
|
|
274
271
|
//////////////////////////////////////////////////////////////////
|
|
275
272
|
// create needed indexes for O(1) functioning
|
|
276
|
-
|
|
273
|
+
_ensureIndexes (cb) {
|
|
277
274
|
this._col.createIndex ({mature : 1}, err => {
|
|
278
275
|
if (err) return cb (err);
|
|
279
|
-
this._col.createIndex({processed: 1}, {expireAfterSeconds: this._opts.ttl}, err => cb (err));
|
|
276
|
+
this._col.createIndex({processed: 1}, {expireAfterSeconds: this._opts.ttl}, err => cb (err, this));
|
|
280
277
|
});
|
|
281
278
|
}
|
|
282
279
|
}
|
|
@@ -289,10 +286,16 @@ class Factory extends QFactory_MongoDB_defaults {
|
|
|
289
286
|
this._db = mongo_conn.db();
|
|
290
287
|
}
|
|
291
288
|
|
|
292
|
-
queue (name, opts) {
|
|
293
|
-
|
|
289
|
+
queue (name, opts, cb) {
|
|
290
|
+
if (!cb) {
|
|
291
|
+
cb = opts;
|
|
292
|
+
opts = {};
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const full_opts = {};
|
|
294
296
|
_.merge(full_opts, this._opts, opts);
|
|
295
|
-
|
|
297
|
+
const q = new PersistentMongoQueue (name, this, full_opts, opts);
|
|
298
|
+
q._ensureIndexes (cb);
|
|
296
299
|
}
|
|
297
300
|
|
|
298
301
|
close (cb) {
|
package/backends/redis-list.js
CHANGED
|
@@ -106,10 +106,15 @@ class Factory extends QFactory {
|
|
|
106
106
|
this._rediscl = rediscl;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
queue (name, opts) {
|
|
110
|
-
|
|
109
|
+
queue (name, opts, cb) {
|
|
110
|
+
if (!cb) {
|
|
111
|
+
cb = opts;
|
|
112
|
+
opts = {};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const full_opts = {};
|
|
111
116
|
_.merge(full_opts, this._opts, opts);
|
|
112
|
-
return new RedisListQueue (name, this, full_opts, opts);
|
|
117
|
+
return setImmediate(() => cb (null, new RedisListQueue (name, this, full_opts, opts)));
|
|
113
118
|
}
|
|
114
119
|
|
|
115
120
|
close (cb) {
|
|
@@ -143,8 +148,3 @@ function creator (opts, cb) {
|
|
|
143
148
|
}
|
|
144
149
|
|
|
145
150
|
module.exports = creator;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
package/backends/redis-oq.js
CHANGED
|
@@ -128,10 +128,15 @@ class Factory extends QFactory {
|
|
|
128
128
|
this._roq_factory = roq_factory;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
queue (name, opts) {
|
|
132
|
-
|
|
131
|
+
queue (name, opts, cb) {
|
|
132
|
+
if (!cb) {
|
|
133
|
+
cb = opts;
|
|
134
|
+
opts = {};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const full_opts = {};
|
|
133
138
|
_.merge(full_opts, this._opts, opts);
|
|
134
|
-
return new RedisOQ (name, this, full_opts, opts);
|
|
139
|
+
return setImmediate (() => cb (null, new RedisOQ (name, this, full_opts, opts)));
|
|
135
140
|
}
|
|
136
141
|
|
|
137
142
|
close (cb) {
|
package/backends/stream-mongo.js
CHANGED
|
@@ -17,21 +17,11 @@ class StreamMongoQueue extends Queue {
|
|
|
17
17
|
|
|
18
18
|
if (!this._opts.ttl) this._opts.ttl = 3600;
|
|
19
19
|
|
|
20
|
-
this._factory = factory;
|
|
21
20
|
this._col = factory._db.collection (name);
|
|
22
21
|
this._groups_str = this._opts.groups || 'A,B:C';
|
|
23
22
|
this._groups_vector = this._groups_str.split (/[:,;.-]/).map (i => i.trim());
|
|
24
23
|
this._gid = this._opts.group || this._groups_vector[0];
|
|
25
24
|
|
|
26
|
-
this.ensureIndexes (err => {
|
|
27
|
-
if (err) {
|
|
28
|
-
console.error ('keuss:Queue:StreamMongo: index creation failed, queues performance will be severely impacted:', err);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
debug ('indexes created');
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
|
|
35
25
|
debug ('created with groups %j and gid %s (used for pop/reserve only)', this._groups_vector, this._gid);
|
|
36
26
|
}
|
|
37
27
|
|
|
@@ -70,7 +60,6 @@ class StreamMongoQueue extends Queue {
|
|
|
70
60
|
|
|
71
61
|
this._col.insertOne (entry, {}, (err, result) => {
|
|
72
62
|
if (err) return callback (err);
|
|
73
|
-
// TODO result.insertedCount must be 1
|
|
74
63
|
callback (null, result.insertedId);
|
|
75
64
|
this._groups_vector.forEach (i => this._stats.incr (`stream.${i}.put`));
|
|
76
65
|
});
|
|
@@ -403,7 +392,7 @@ class StreamMongoQueue extends Queue {
|
|
|
403
392
|
|
|
404
393
|
//////////////////////////////////////////////////////////////////
|
|
405
394
|
// create needed indexes for O(1) functioning
|
|
406
|
-
|
|
395
|
+
_ensureIndexes (cb) {
|
|
407
396
|
const tasks = [];
|
|
408
397
|
|
|
409
398
|
this._groups_vector.forEach (i => {
|
|
@@ -412,7 +401,7 @@ class StreamMongoQueue extends Queue {
|
|
|
412
401
|
tasks.push (cb => this._col.createIndex (idx, cb));
|
|
413
402
|
});
|
|
414
403
|
tasks.push (cb => this._col.createIndex ({t: 1}, {expireAfterSeconds: this._opts.ttl}, cb));
|
|
415
|
-
async.series (tasks, cb);
|
|
404
|
+
async.series (tasks, err => cb (err, this));
|
|
416
405
|
}
|
|
417
406
|
}
|
|
418
407
|
|
|
@@ -424,10 +413,16 @@ class Factory extends QFactory_MongoDB_defaults {
|
|
|
424
413
|
this._db = mongo_conn.db();
|
|
425
414
|
}
|
|
426
415
|
|
|
427
|
-
queue (name, opts) {
|
|
416
|
+
queue (name, opts, cb) {
|
|
417
|
+
if (!cb) {
|
|
418
|
+
cb = opts;
|
|
419
|
+
opts = {};
|
|
420
|
+
}
|
|
421
|
+
|
|
428
422
|
const full_opts = {};
|
|
429
423
|
_.merge(full_opts, this._opts, opts);
|
|
430
|
-
|
|
424
|
+
const q = new StreamMongoQueue (name, this, full_opts, opts);
|
|
425
|
+
q._ensureIndexes (cb);
|
|
431
426
|
}
|
|
432
427
|
|
|
433
428
|
close (cb) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keuss",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"queue",
|
|
6
6
|
"persistent",
|
|
7
7
|
"job",
|
|
8
8
|
"mongodb",
|
|
9
|
+
"postgres",
|
|
10
|
+
"postgresql",
|
|
9
11
|
"redis",
|
|
10
12
|
"HA",
|
|
11
13
|
"pipeline",
|
|
@@ -27,19 +29,21 @@
|
|
|
27
29
|
"license": "MIT",
|
|
28
30
|
"dependencies": {
|
|
29
31
|
"@nodebb/mubsub": "~1.8.0",
|
|
30
|
-
"async": "~3.2.
|
|
31
|
-
"async-lock": "~1.
|
|
32
|
-
"debug": "~4.3.
|
|
33
|
-
"ioredis": "~5.
|
|
32
|
+
"async": "~3.2.5",
|
|
33
|
+
"async-lock": "~1.4.1",
|
|
34
|
+
"debug": "~4.3.5",
|
|
35
|
+
"ioredis": "~5.4.1",
|
|
34
36
|
"lodash": "~4.17.21",
|
|
35
|
-
"mitt": "~3.0.
|
|
37
|
+
"mitt": "~3.0.1",
|
|
36
38
|
"mongodb": "~4.17.0",
|
|
37
|
-
"uuid": "~8.3.2"
|
|
39
|
+
"uuid": "~8.3.2",
|
|
40
|
+
"pg": "~8.12.0"
|
|
38
41
|
},
|
|
39
42
|
"devDependencies": {
|
|
40
43
|
"chance": "~1.1.11",
|
|
41
|
-
"mocha": "~10.
|
|
44
|
+
"mocha": "~10.4.0",
|
|
42
45
|
"should": "~13.2.3",
|
|
46
|
+
"nyc": "~15.1.0",
|
|
43
47
|
"why-is-node-running": "^2.2.2"
|
|
44
48
|
},
|
|
45
49
|
"scripts": {
|
package/stats/mem.js
CHANGED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
# For most projects, this workflow file will not need changing; you simply need
|
|
2
|
-
# to commit it to your repository.
|
|
3
|
-
#
|
|
4
|
-
# You may wish to alter this file to override the set of languages analyzed,
|
|
5
|
-
# or to provide custom queries or build logic.
|
|
6
|
-
#
|
|
7
|
-
# ******** NOTE ********
|
|
8
|
-
# We have attempted to detect the languages in your repository. Please check
|
|
9
|
-
# the `language` matrix defined below to confirm you have the correct set of
|
|
10
|
-
# supported CodeQL languages.
|
|
11
|
-
#
|
|
12
|
-
name: "CodeQL"
|
|
13
|
-
|
|
14
|
-
on:
|
|
15
|
-
push:
|
|
16
|
-
branches: [ master ]
|
|
17
|
-
pull_request:
|
|
18
|
-
# The branches below must be a subset of the branches above
|
|
19
|
-
branches: [ master ]
|
|
20
|
-
schedule:
|
|
21
|
-
- cron: '26 13 * * 1'
|
|
22
|
-
|
|
23
|
-
jobs:
|
|
24
|
-
analyze:
|
|
25
|
-
name: Analyze
|
|
26
|
-
runs-on: ubuntu-latest
|
|
27
|
-
permissions:
|
|
28
|
-
actions: read
|
|
29
|
-
contents: read
|
|
30
|
-
security-events: write
|
|
31
|
-
|
|
32
|
-
strategy:
|
|
33
|
-
fail-fast: false
|
|
34
|
-
matrix:
|
|
35
|
-
language: [ 'javascript' ]
|
|
36
|
-
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
|
37
|
-
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
|
|
38
|
-
|
|
39
|
-
steps:
|
|
40
|
-
- name: Checkout repository
|
|
41
|
-
uses: actions/checkout@v3
|
|
42
|
-
|
|
43
|
-
# Initializes the CodeQL tools for scanning.
|
|
44
|
-
- name: Initialize CodeQL
|
|
45
|
-
uses: github/codeql-action/init@v2
|
|
46
|
-
with:
|
|
47
|
-
languages: ${{ matrix.language }}
|
|
48
|
-
# If you wish to specify custom queries, you can do so here or in a config file.
|
|
49
|
-
# By default, queries listed here will override any specified in a config file.
|
|
50
|
-
# Prefix the list here with "+" to use these queries and those in the config file.
|
|
51
|
-
|
|
52
|
-
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
|
53
|
-
# queries: security-extended,security-and-quality
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
|
57
|
-
# If this step fails, then you should remove it and run the build manually (see below)
|
|
58
|
-
- name: Autobuild
|
|
59
|
-
uses: github/codeql-action/autobuild@v2
|
|
60
|
-
|
|
61
|
-
# ℹ️ Command-line programs to run using the OS shell.
|
|
62
|
-
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
|
63
|
-
|
|
64
|
-
# If the Autobuild fails above, remove it and uncomment the following three lines.
|
|
65
|
-
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
|
|
66
|
-
|
|
67
|
-
# - run: |
|
|
68
|
-
# echo "Run, Build Application using script"
|
|
69
|
-
# ./location_of_script_within_repo/buildscript.sh
|
|
70
|
-
|
|
71
|
-
- name: Perform CodeQL Analysis
|
|
72
|
-
uses: github/codeql-action/analyze@v2
|
package/bench/all-mongo.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
var async = require ('async');
|
|
3
|
-
|
|
4
|
-
var MQ = require('../backends/mongo');
|
|
5
|
-
//var signal_mongo_capped = require('../signal/mongo-capped');
|
|
6
|
-
var signal_mongo_capped = require('../signal/local');
|
|
7
|
-
var stats_mongo = require('../stats/mongo');
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var factory_opts = {
|
|
11
|
-
url: 'mongodb://localhost/qeus',
|
|
12
|
-
signaller: {
|
|
13
|
-
provider: signal_mongo_capped,
|
|
14
|
-
opts: {
|
|
15
|
-
url: 'mongodb://localhost/qeus_signal',
|
|
16
|
-
channel: 'das_channel'
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
stats: {
|
|
20
|
-
provider: stats_mongo,
|
|
21
|
-
opts: {
|
|
22
|
-
url: 'mongodb://localhost/qeus_stats'
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// initialize factory
|
|
29
|
-
MQ(factory_opts, (err, factory) => {
|
|
30
|
-
if (err) {
|
|
31
|
-
return console.error(err);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
var consumed = 0;
|
|
35
|
-
var produced = 0;
|
|
36
|
-
|
|
37
|
-
function run_consumer(q) {
|
|
38
|
-
q.pop('c1', {}, (err, res) => {
|
|
39
|
-
// console.log('consumer[%s]: got res %j', q.name(), res, {});
|
|
40
|
-
consumed++;
|
|
41
|
-
|
|
42
|
-
if (consumed > 100) {
|
|
43
|
-
factory.close();
|
|
44
|
-
} else {
|
|
45
|
-
if (!(consumed % 10)) console.log('< %d', consumed);
|
|
46
|
-
|
|
47
|
-
setTimeout(function () {
|
|
48
|
-
run_consumer(q);
|
|
49
|
-
}, 222);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function run_producer(q) {
|
|
55
|
-
q.push({
|
|
56
|
-
a: 1,
|
|
57
|
-
b: '666',
|
|
58
|
-
t: new Date(),
|
|
59
|
-
n: produced
|
|
60
|
-
}, (err, res) => {
|
|
61
|
-
produced++;
|
|
62
|
-
|
|
63
|
-
if (produced > 3) {
|
|
64
|
-
|
|
65
|
-
} else {
|
|
66
|
-
if (!(produced % 10)) console.log('> %d', produced);
|
|
67
|
-
|
|
68
|
-
setTimeout(function () {
|
|
69
|
-
run_producer(q);
|
|
70
|
-
}, 33);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
var opts = {};
|
|
76
|
-
|
|
77
|
-
var q = factory.queue('bench_test_queue_0', opts);
|
|
78
|
-
// run_consumer(q);
|
|
79
|
-
// run_producer(q);
|
|
80
|
-
|
|
81
|
-
async.series ([
|
|
82
|
-
cb => q.push ({q:0, a: 'ryetyeryre 0'}, cb),
|
|
83
|
-
cb => q.push ({q:1, a: 'ryetyeryre 1'}, cb),
|
|
84
|
-
cb => q.pop ('me', (err, res) => {console.log ('>>>>>>> POP c0:', res); cb ();}),
|
|
85
|
-
cb => q.pop ('me', (err, res) => {console.log ('>>>>>>> POP c1:', res); cb ();}),
|
|
86
|
-
|
|
87
|
-
cb => {
|
|
88
|
-
q.pop ('me', (err, res) => console.log ('>>>>>>> POP c2:', res));
|
|
89
|
-
q.pop ('me', (err, res) => console.log ('>>>>>>> POP c3:', res));
|
|
90
|
-
q.pop ('me', (err, res) => console.log ('>>>>>>> POP c4:', res));
|
|
91
|
-
q.pop ('me', (err, res) => console.log ('>>>>>>> POP c5:', res));
|
|
92
|
-
q.pop ('me', (err, res) => console.log ('>>>>>>> POP c6:', res));
|
|
93
|
-
cb ();
|
|
94
|
-
},
|
|
95
|
-
cb => setTimeout (cb, 2000),
|
|
96
|
-
cb => {q.pause(true); cb ();},
|
|
97
|
-
cb => q.push ({q:2, a: 'ryetyeryre 2'}, cb),
|
|
98
|
-
cb => q.push ({q:3, a: 'ryetyeryre 3'}, cb),
|
|
99
|
-
cb => q.push ({q:4, a: 'ryetyeryre 4'}, cb),
|
|
100
|
-
cb => q.push ({q:5, a: 'ryetyeryre 5'}, cb),
|
|
101
|
-
cb => setTimeout (cb, 2000),
|
|
102
|
-
cb => {q.pause(false); cb ();},
|
|
103
|
-
cb => setTimeout (cb, 2000),
|
|
104
|
-
], () => {
|
|
105
|
-
q.cancel();
|
|
106
|
-
factory.close();
|
|
107
|
-
});
|
|
108
|
-
});
|
package/bench/multi-q.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
var async = require ('async');
|
|
2
|
-
var should = require ('should');
|
|
3
|
-
var Chance = require ('chance');
|
|
4
|
-
|
|
5
|
-
var produced = 0;
|
|
6
|
-
var consumed = 0;
|
|
7
|
-
|
|
8
|
-
var chance = new Chance();
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
//var MQ = require ('../backends/redis-oq');
|
|
12
|
-
//var MQ = require ('../backends/redis-list');
|
|
13
|
-
//var MQ = require ('../backends/mongo');
|
|
14
|
-
var MQ = require ('../backends/pl-mongo');
|
|
15
|
-
|
|
16
|
-
var redis_signaller = require ('../signal/redis-pubsub');
|
|
17
|
-
var redis_stats = require ('../stats/redis');
|
|
18
|
-
|
|
19
|
-
var opts = {
|
|
20
|
-
signaller: {
|
|
21
|
-
provider: new redis_signaller ()
|
|
22
|
-
},
|
|
23
|
-
stats: {
|
|
24
|
-
provider: new redis_stats ()
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
MQ (opts, function (err, factory) {
|
|
29
|
-
if (err) {
|
|
30
|
-
return console.error (err);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
function run_consumer (q) {
|
|
35
|
-
q.pop ('c1', {}, function (err, res) {
|
|
36
|
-
// console.log ('consumer[%s]: got res %j', q.name(), res, {});
|
|
37
|
-
consumed++;
|
|
38
|
-
|
|
39
|
-
if (consumed > 1000000) {
|
|
40
|
-
factory.close ();
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
if (!(consumed % 10000)) console.log ('< %d', consumed)
|
|
44
|
-
// setTimeout (function () {
|
|
45
|
-
run_consumer (q);
|
|
46
|
-
// }, chance.integer({ min: 200, max: 2000 }));
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function run_producer (q) {
|
|
52
|
-
q.push ({a:1, b:'666'}, function (err, res) {
|
|
53
|
-
produced++;
|
|
54
|
-
|
|
55
|
-
if (produced > 1000000) {
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
if (!(produced % 10000)) console.log ('> %d', produced)
|
|
60
|
-
// setTimeout (function () {
|
|
61
|
-
run_producer (q);
|
|
62
|
-
// }, chance.integer({ min: 200, max: 2000 }));
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
var q0 = factory.queue('bench_test_queue_0', opts);
|
|
70
|
-
run_consumer (q0);
|
|
71
|
-
run_producer (q0);
|
|
72
|
-
/*
|
|
73
|
-
var q1 = factory.queue('bench_test_queue_1', opts);
|
|
74
|
-
run_consumer (q1);
|
|
75
|
-
run_producer (q1);
|
|
76
|
-
|
|
77
|
-
var q2 = factory.queue('bench_test_queue_2', opts);
|
|
78
|
-
run_consumer (q2);
|
|
79
|
-
run_producer (q2);
|
|
80
|
-
|
|
81
|
-
var q3 = factory.queue('bench_test_queue_3', opts);
|
|
82
|
-
run_consumer (q3);
|
|
83
|
-
run_producer (q3);
|
|
84
|
-
*/
|
|
85
|
-
});
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
var async = require ('async');
|
|
2
|
-
var should = require ('should');
|
|
3
|
-
var Chance = require ('chance');
|
|
4
|
-
|
|
5
|
-
var chance = new Chance();
|
|
6
|
-
|
|
7
|
-
function run_consumer (q) {
|
|
8
|
-
q.pop ('c1', {}, function (err, res) {
|
|
9
|
-
console.log ('consumer: got err %j', err, {});
|
|
10
|
-
console.log ('consumer: got res %j', res, {});
|
|
11
|
-
|
|
12
|
-
// setTimeout (function () {
|
|
13
|
-
run_consumer (q);
|
|
14
|
-
// }, chance.integer({ min: 200, max: 2000 }));
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function run_producer (q) {
|
|
19
|
-
q.push ({a:1, b:'666'}, function (err, res) {
|
|
20
|
-
console.log ('producer: got err %j', err, {});
|
|
21
|
-
console.log ('producer: got res %j', res, {});
|
|
22
|
-
|
|
23
|
-
setTimeout (function () {
|
|
24
|
-
run_producer (q);
|
|
25
|
-
}, (random.from0to (10) + 1) * 1000);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var MQ = require ('../backends/redis-oq');
|
|
31
|
-
var redis_signaller = require ('../signal/redis-pubsub');
|
|
32
|
-
var redis_stats = require ('../stats/redis');
|
|
33
|
-
|
|
34
|
-
var opts = {
|
|
35
|
-
signaller: {
|
|
36
|
-
provider: new redis_signaller ()
|
|
37
|
-
},
|
|
38
|
-
stats: {
|
|
39
|
-
provider: new redis_stats ()
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
MQ (opts, function (err, factory) {
|
|
44
|
-
if (err) {
|
|
45
|
-
return logger.error (err);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
var q = factory.queue('bench_test_queue', opts);
|
|
49
|
-
|
|
50
|
-
run_consumer (q);
|
|
51
|
-
run_producer (q);
|
|
52
|
-
});
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
var async = require ('async');
|
|
2
|
-
var should = require ('should');
|
|
3
|
-
|
|
4
|
-
var counter = 0;
|
|
5
|
-
|
|
6
|
-
function run_consumer (q) {
|
|
7
|
-
q.pop ('c1', {}, function (err, res) {
|
|
8
|
-
console.log ('consumer: got err %j', err, {});
|
|
9
|
-
console.log ('consumer: got res %j', res, {});
|
|
10
|
-
|
|
11
|
-
counter++;
|
|
12
|
-
logger.info ('consumer: got %d', counter);
|
|
13
|
-
run_consumer (q);
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
var MQ = require ('../backends/redis-oq');
|
|
18
|
-
|
|
19
|
-
var opts = {
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
MQ (opts, function (err, factory) {
|
|
23
|
-
if (err) {
|
|
24
|
-
return logger.error (err);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
var q_opts = {
|
|
28
|
-
logger: logger,
|
|
29
|
-
signaller: {
|
|
30
|
-
provider: require ('../signal/redis-pubsub')
|
|
31
|
-
},
|
|
32
|
-
stats: {
|
|
33
|
-
provider: require ('../stats/redis')
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
var q = factory.queue ('test_queue', q_opts);
|
|
38
|
-
|
|
39
|
-
run_consumer (q);
|
|
40
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
var async = require ('async');
|
|
2
|
-
var should = require ('should');
|
|
3
|
-
|
|
4
|
-
var counter = 0;
|
|
5
|
-
|
|
6
|
-
function run_producer (q) {
|
|
7
|
-
q.push ({a:1, b:'666'}, function (err, res) {
|
|
8
|
-
console.log ('producer: got err %j', err, {});
|
|
9
|
-
console.log('producer: got res %j', res, {});
|
|
10
|
-
|
|
11
|
-
counter++;
|
|
12
|
-
console.log('producer: got %d', counter);
|
|
13
|
-
setTimeout (function () {
|
|
14
|
-
run_producer (q);
|
|
15
|
-
}, 333);
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var MQ = require ('../backends/redis-oq');
|
|
21
|
-
|
|
22
|
-
var opts = {
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
MQ (opts, function (err, factory) {
|
|
26
|
-
if (err) {
|
|
27
|
-
return logger.error (err);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
var q_opts = {
|
|
31
|
-
logger: logger,
|
|
32
|
-
signaller: {
|
|
33
|
-
provider: require ('../signal/redis-pubsub')
|
|
34
|
-
},
|
|
35
|
-
stats: {
|
|
36
|
-
provider: require ('../stats/redis')
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
var q = factory.queue ('test_queue', q_opts);
|
|
41
|
-
|
|
42
|
-
run_producer (q);
|
|
43
|
-
});
|
package/docker-compose.yaml
DELETED