rascal 13.1.2 → 13.1.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/.husky/pre-commit +1 -1
- package/.prettierrc.json +1 -0
- package/CHANGELOG.md +195 -1
- package/README.md +630 -395
- package/examples/advanced/cluster.js +8 -8
- package/examples/advanced/config.js +117 -114
- package/examples/advanced/handlers/deleteUser.js +23 -17
- package/examples/advanced/handlers/saveUser.js +38 -32
- package/examples/advanced/index.js +105 -78
- package/examples/busy-publisher/config.js +14 -17
- package/examples/busy-publisher/index.js +27 -22
- package/examples/default-exchange/config.js +10 -10
- package/examples/default-exchange/index.js +27 -18
- package/examples/mocha/config.js +9 -11
- package/examples/mocha/test.js +42 -35
- package/examples/promises/config.js +11 -13
- package/examples/promises/index.js +24 -17
- package/examples/simple/config.js +16 -18
- package/examples/simple/index.js +25 -23
- package/index.js +7 -7
- package/lib/amqp/Broker.js +154 -99
- package/lib/amqp/BrokerAsPromised.js +56 -35
- package/lib/amqp/Publication.js +219 -78
- package/lib/amqp/PublicationSession.js +13 -14
- package/lib/amqp/SubscriberError.js +293 -132
- package/lib/amqp/SubscriberSession.js +95 -56
- package/lib/amqp/SubscriberSessionAsPromised.js +4 -6
- package/lib/amqp/Subscription.js +328 -109
- package/lib/amqp/Vhost.js +341 -170
- package/lib/amqp/tasks/applyBindings.js +51 -18
- package/lib/amqp/tasks/assertExchanges.js +20 -11
- package/lib/amqp/tasks/assertQueues.js +13 -9
- package/lib/amqp/tasks/assertVhost.js +21 -17
- package/lib/amqp/tasks/bounceVhost.js +1 -1
- package/lib/amqp/tasks/checkExchanges.js +13 -9
- package/lib/amqp/tasks/checkQueues.js +13 -9
- package/lib/amqp/tasks/checkVhost.js +21 -17
- package/lib/amqp/tasks/closeChannel.js +3 -4
- package/lib/amqp/tasks/closeConnection.js +3 -3
- package/lib/amqp/tasks/createChannel.js +3 -4
- package/lib/amqp/tasks/createConnection.js +71 -53
- package/lib/amqp/tasks/deleteExchanges.js +14 -10
- package/lib/amqp/tasks/deleteQueues.js +13 -9
- package/lib/amqp/tasks/deleteVhost.js +26 -17
- package/lib/amqp/tasks/forewarnVhost.js +1 -1
- package/lib/amqp/tasks/index.js +25 -25
- package/lib/amqp/tasks/initCounters.js +18 -13
- package/lib/amqp/tasks/initPublications.js +17 -13
- package/lib/amqp/tasks/initShovels.js +29 -20
- package/lib/amqp/tasks/initSubscriptions.js +23 -13
- package/lib/amqp/tasks/initVhosts.js +21 -17
- package/lib/amqp/tasks/nukeVhost.js +1 -1
- package/lib/amqp/tasks/purgeQueues.js +13 -9
- package/lib/amqp/tasks/purgeVhost.js +1 -1
- package/lib/amqp/tasks/shutdownVhost.js +1 -1
- package/lib/backoff/exponential.js +9 -8
- package/lib/backoff/index.js +3 -3
- package/lib/backoff/linear.js +5 -7
- package/lib/config/baseline.js +25 -35
- package/lib/config/configure.js +274 -101
- package/lib/config/fqn.js +3 -3
- package/lib/config/tests.js +32 -29
- package/lib/config/validate.js +460 -70
- package/lib/counters/inMemory.js +3 -3
- package/lib/counters/inMemoryCluster.js +48 -30
- package/lib/counters/index.js +4 -4
- package/lib/counters/stub.js +2 -3
- package/lib/management/client.js +47 -17
- package/lib/utils/setTimeoutUnref.js +1 -1
- package/package.json +12 -4
|
@@ -1,40 +1,73 @@
|
|
|
1
|
-
const debug = require(
|
|
2
|
-
const format = require(
|
|
3
|
-
const _ = require(
|
|
4
|
-
const async = require(
|
|
1
|
+
const debug = require("debug")("rascal:tasks:applyBindings");
|
|
2
|
+
const format = require("util").format;
|
|
3
|
+
const _ = require("lodash");
|
|
4
|
+
const async = require("async");
|
|
5
5
|
|
|
6
6
|
module.exports = _.curry((config, ctx, next) => {
|
|
7
|
-
|
|
8
7
|
const bind = {
|
|
9
8
|
queue: bindQueue,
|
|
10
9
|
exchange: bindExchange,
|
|
11
10
|
};
|
|
12
11
|
|
|
13
|
-
async.eachSeries(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
async.eachSeries(
|
|
13
|
+
_.values(config.bindings),
|
|
14
|
+
(binding, callback) => {
|
|
15
|
+
bind[binding.destinationType](config, ctx.channel, binding, callback);
|
|
16
|
+
},
|
|
17
|
+
(err) => {
|
|
18
|
+
next(err, config, ctx);
|
|
19
|
+
}
|
|
20
|
+
);
|
|
18
21
|
});
|
|
19
22
|
|
|
20
23
|
function bindQueue(config, channel, binding, next) {
|
|
21
24
|
const destination = config.queues[binding.destination];
|
|
22
|
-
if (!destination)
|
|
25
|
+
if (!destination)
|
|
26
|
+
return next(
|
|
27
|
+
new Error(format("Unknown destination: %s", binding.destination))
|
|
28
|
+
);
|
|
23
29
|
|
|
24
30
|
const source = config.exchanges[binding.source];
|
|
25
|
-
if (!source)
|
|
31
|
+
if (!source)
|
|
32
|
+
return next(new Error(format("Unknown source: %s", binding.source)));
|
|
26
33
|
|
|
27
|
-
debug(
|
|
28
|
-
|
|
34
|
+
debug(
|
|
35
|
+
"Binding queue: %s to exchange: %s with binding key: %s",
|
|
36
|
+
destination.fullyQualifiedName,
|
|
37
|
+
source.fullyQualifiedName,
|
|
38
|
+
binding.bindingKey
|
|
39
|
+
);
|
|
40
|
+
channel.bindQueue(
|
|
41
|
+
destination.fullyQualifiedName,
|
|
42
|
+
source.fullyQualifiedName,
|
|
43
|
+
binding.bindingKey,
|
|
44
|
+
binding.options,
|
|
45
|
+
next
|
|
46
|
+
);
|
|
29
47
|
}
|
|
30
48
|
|
|
31
49
|
function bindExchange(config, channel, binding, next) {
|
|
32
50
|
const destination = config.exchanges[binding.destination];
|
|
33
|
-
if (!destination)
|
|
51
|
+
if (!destination)
|
|
52
|
+
return next(
|
|
53
|
+
new Error(format("Unknown destination: %s", binding.destination))
|
|
54
|
+
);
|
|
34
55
|
|
|
35
56
|
const source = config.exchanges[binding.source];
|
|
36
|
-
if (!source)
|
|
57
|
+
if (!source)
|
|
58
|
+
return next(new Error(format("Unknown source: %s", binding.source)));
|
|
37
59
|
|
|
38
|
-
debug(
|
|
39
|
-
|
|
60
|
+
debug(
|
|
61
|
+
"Binding exchange: %s to exchange: %s with binding key: %s",
|
|
62
|
+
destination.fullyQualifiedName,
|
|
63
|
+
source.fullyQualifiedName,
|
|
64
|
+
binding.bindingKey
|
|
65
|
+
);
|
|
66
|
+
channel.bindExchange(
|
|
67
|
+
destination.fullyQualifiedName,
|
|
68
|
+
source.fullyQualifiedName,
|
|
69
|
+
binding.bindingKey,
|
|
70
|
+
binding.options,
|
|
71
|
+
next
|
|
72
|
+
);
|
|
40
73
|
}
|
|
@@ -1,18 +1,27 @@
|
|
|
1
|
-
const debug = require(
|
|
2
|
-
const _ = require(
|
|
3
|
-
const async = require(
|
|
1
|
+
const debug = require("debug")("rascal:tasks:assertExchanges");
|
|
2
|
+
const _ = require("lodash");
|
|
3
|
+
const async = require("async");
|
|
4
4
|
|
|
5
5
|
module.exports = _.curry((config, ctx, next) => {
|
|
6
|
-
async.eachSeries(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
async.eachSeries(
|
|
7
|
+
_.keys(config.exchanges),
|
|
8
|
+
(name, callback) => {
|
|
9
|
+
assertExchange(ctx.channel, config.exchanges[name], callback);
|
|
10
|
+
},
|
|
11
|
+
(err) => {
|
|
12
|
+
next(err, config, ctx);
|
|
13
|
+
}
|
|
14
|
+
);
|
|
11
15
|
});
|
|
12
16
|
|
|
13
17
|
function assertExchange(channel, config, next) {
|
|
14
18
|
if (!config.assert) return next();
|
|
15
|
-
if (config.fullyQualifiedName ===
|
|
16
|
-
debug(
|
|
17
|
-
channel.assertExchange(
|
|
19
|
+
if (config.fullyQualifiedName === "") return next();
|
|
20
|
+
debug("Asserting exchange: %s", config.fullyQualifiedName);
|
|
21
|
+
channel.assertExchange(
|
|
22
|
+
config.fullyQualifiedName,
|
|
23
|
+
config.type,
|
|
24
|
+
config.options,
|
|
25
|
+
next
|
|
26
|
+
);
|
|
18
27
|
}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
const debug = require(
|
|
2
|
-
const _ = require(
|
|
3
|
-
const async = require(
|
|
1
|
+
const debug = require("debug")("rascal:tasks:assertQueues");
|
|
2
|
+
const _ = require("lodash");
|
|
3
|
+
const async = require("async");
|
|
4
4
|
|
|
5
5
|
module.exports = _.curry((config, ctx, next) => {
|
|
6
|
-
async.eachSeries(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
async.eachSeries(
|
|
7
|
+
_.keys(config.queues),
|
|
8
|
+
(name, callback) => {
|
|
9
|
+
assertQueue(ctx.channel, config.queues[name], callback);
|
|
10
|
+
},
|
|
11
|
+
(err) => {
|
|
12
|
+
next(err, config, ctx);
|
|
13
|
+
}
|
|
14
|
+
);
|
|
11
15
|
});
|
|
12
16
|
|
|
13
17
|
function assertQueue(channel, config, next) {
|
|
14
18
|
if (!config.assert) return next();
|
|
15
|
-
debug(
|
|
19
|
+
debug("Asserting queue: %s", config.fullyQualifiedName);
|
|
16
20
|
channel.assertQueue(config.fullyQualifiedName, config.options, next);
|
|
17
21
|
}
|
|
@@ -1,23 +1,27 @@
|
|
|
1
|
-
const debug = require(
|
|
2
|
-
const _ = require(
|
|
3
|
-
const async = require(
|
|
4
|
-
const client = require(
|
|
1
|
+
const debug = require("debug")("rascal:tasks:assertVhost");
|
|
2
|
+
const _ = require("lodash");
|
|
3
|
+
const async = require("async");
|
|
4
|
+
const client = require("../../management/client");
|
|
5
5
|
|
|
6
6
|
module.exports = _.curry((config, ctx, next) => {
|
|
7
7
|
if (!config.assert) return next(null, config, ctx);
|
|
8
8
|
const candidates = config.connections;
|
|
9
9
|
|
|
10
|
-
async.retry(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
async.retry(
|
|
11
|
+
candidates.length,
|
|
12
|
+
(cb) => {
|
|
13
|
+
const connectionConfig = candidates[ctx.connectionIndex];
|
|
14
|
+
client.assertVhost(config.name, connectionConfig.management, (err) => {
|
|
15
|
+
if (err) {
|
|
16
|
+
ctx.connectionIndex = (ctx.connectionIndex + 1) % candidates.length;
|
|
17
|
+
return cb(err);
|
|
18
|
+
}
|
|
19
|
+
ctx.connectionConfig = connectionConfig;
|
|
20
|
+
cb();
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
(err) => {
|
|
24
|
+
next(err, config, ctx);
|
|
25
|
+
}
|
|
26
|
+
);
|
|
23
27
|
});
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
const debug = require(
|
|
2
|
-
const _ = require(
|
|
3
|
-
const async = require(
|
|
1
|
+
const debug = require("debug")("rascal:tasks:checkExchanges");
|
|
2
|
+
const _ = require("lodash");
|
|
3
|
+
const async = require("async");
|
|
4
4
|
|
|
5
5
|
module.exports = _.curry((config, ctx, next) => {
|
|
6
|
-
async.eachSeries(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
async.eachSeries(
|
|
7
|
+
_.keys(config.exchanges),
|
|
8
|
+
(name, callback) => {
|
|
9
|
+
checkExchange(ctx.channel, config.exchanges[name], callback);
|
|
10
|
+
},
|
|
11
|
+
(err) => {
|
|
12
|
+
next(err, config, ctx);
|
|
13
|
+
}
|
|
14
|
+
);
|
|
11
15
|
});
|
|
12
16
|
|
|
13
17
|
function checkExchange(channel, config, next) {
|
|
14
18
|
if (!config.check) return next();
|
|
15
|
-
debug(
|
|
19
|
+
debug("Checking exchange: %s", config.fullyQualifiedName);
|
|
16
20
|
channel.checkExchange(config.fullyQualifiedName, next);
|
|
17
21
|
}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
const debug = require(
|
|
2
|
-
const _ = require(
|
|
3
|
-
const async = require(
|
|
1
|
+
const debug = require("debug")("rascal:tasks:checkQueues");
|
|
2
|
+
const _ = require("lodash");
|
|
3
|
+
const async = require("async");
|
|
4
4
|
|
|
5
5
|
module.exports = _.curry((config, ctx, next) => {
|
|
6
|
-
async.eachSeries(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
async.eachSeries(
|
|
7
|
+
_.keys(config.queues),
|
|
8
|
+
(name, callback) => {
|
|
9
|
+
checkQueue(ctx.channel, config.queues[name], callback);
|
|
10
|
+
},
|
|
11
|
+
(err) => {
|
|
12
|
+
next(err, config, ctx);
|
|
13
|
+
}
|
|
14
|
+
);
|
|
11
15
|
});
|
|
12
16
|
|
|
13
17
|
function checkQueue(channel, config, next) {
|
|
14
18
|
if (!config.check) return next();
|
|
15
|
-
debug(
|
|
19
|
+
debug("Checking queue: %s", config.fullyQualifiedName);
|
|
16
20
|
channel.checkQueue(config.fullyQualifiedName, next);
|
|
17
21
|
}
|
|
@@ -1,23 +1,27 @@
|
|
|
1
|
-
const debug = require(
|
|
2
|
-
const _ = require(
|
|
3
|
-
const async = require(
|
|
4
|
-
const client = require(
|
|
1
|
+
const debug = require("debug")("rascal:tasks:checkVhost");
|
|
2
|
+
const _ = require("lodash");
|
|
3
|
+
const async = require("async");
|
|
4
|
+
const client = require("../../management/client");
|
|
5
5
|
|
|
6
6
|
module.exports = _.curry((config, ctx, next) => {
|
|
7
7
|
if (!config.check) return next(null, config, ctx);
|
|
8
8
|
const candidates = config.connections;
|
|
9
9
|
|
|
10
|
-
async.retry(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
async.retry(
|
|
11
|
+
candidates.length,
|
|
12
|
+
(cb) => {
|
|
13
|
+
const connectionConfig = candidates[ctx.connectionIndex];
|
|
14
|
+
client.checkVhost(config.name, connectionConfig.management, (err) => {
|
|
15
|
+
if (err) {
|
|
16
|
+
ctx.connectionIndex = (ctx.connectionIndex + 1) % candidates.length;
|
|
17
|
+
return cb(err);
|
|
18
|
+
}
|
|
19
|
+
ctx.connectionConfig = connectionConfig;
|
|
20
|
+
cb();
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
(err) => {
|
|
24
|
+
next(err, config, ctx);
|
|
25
|
+
}
|
|
26
|
+
);
|
|
23
27
|
});
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
const debug = require(
|
|
2
|
-
const _ = require(
|
|
1
|
+
const debug = require("debug")("rascal:tasks:closeChannel");
|
|
2
|
+
const _ = require("lodash");
|
|
3
3
|
|
|
4
4
|
module.exports = _.curry((config, ctx, next) => {
|
|
5
|
-
|
|
6
|
-
debug('Closing channel');
|
|
5
|
+
debug("Closing channel");
|
|
7
6
|
|
|
8
7
|
ctx.channel.close((err) => {
|
|
9
8
|
if (err) return next(err, config, ctx);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const debug = require(
|
|
2
|
-
const _ = require(
|
|
1
|
+
const debug = require("debug")("rascal:tasks:checkQueues");
|
|
2
|
+
const _ = require("lodash");
|
|
3
3
|
|
|
4
4
|
module.exports = _.curry((config, ctx, next) => {
|
|
5
|
-
debug(
|
|
5
|
+
debug("Closing connection: %s", ctx.connectionConfig.loggableUrl);
|
|
6
6
|
if (!ctx.connection) return next(null, config, ctx);
|
|
7
7
|
ctx.connection.close((err) => {
|
|
8
8
|
next(err, config, ctx);
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
const debug = require(
|
|
2
|
-
const _ = require(
|
|
1
|
+
const debug = require("debug")("rascal:tasks:createChannel");
|
|
2
|
+
const _ = require("lodash");
|
|
3
3
|
|
|
4
4
|
module.exports = _.curry((config, ctx, next) => {
|
|
5
|
-
|
|
6
|
-
debug('Creating channel');
|
|
5
|
+
debug("Creating channel");
|
|
7
6
|
|
|
8
7
|
ctx.connection.createChannel((err, channel) => {
|
|
9
8
|
if (err) return next(err, config, ctx);
|
|
@@ -1,72 +1,90 @@
|
|
|
1
|
-
const debug = require(
|
|
2
|
-
const _ = require(
|
|
3
|
-
const amqplib = require(
|
|
4
|
-
const async = require(
|
|
5
|
-
const format = require(
|
|
6
|
-
const uuid = require(
|
|
1
|
+
const debug = require("debug")("rascal:tasks:createConnection");
|
|
2
|
+
const _ = require("lodash");
|
|
3
|
+
const amqplib = require("amqplib/callback_api");
|
|
4
|
+
const async = require("async");
|
|
5
|
+
const format = require("util").format;
|
|
6
|
+
const uuid = require("uuid").v4;
|
|
7
7
|
|
|
8
8
|
module.exports = _.curry((config, ctx, next) => {
|
|
9
9
|
const candidates = config.connections;
|
|
10
10
|
|
|
11
|
-
async.retry(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
11
|
+
async.retry(
|
|
12
|
+
candidates.length,
|
|
13
|
+
(cb) => {
|
|
14
|
+
const connectionConfig = candidates[ctx.connectionIndex];
|
|
15
|
+
connect(connectionConfig, (err, connection) => {
|
|
16
|
+
if (err) {
|
|
17
|
+
ctx.connectionIndex = (ctx.connectionIndex + 1) % candidates.length;
|
|
18
|
+
return cb(err);
|
|
19
|
+
}
|
|
20
|
+
ctx.connection = connection;
|
|
21
|
+
ctx.connectionConfig = connectionConfig;
|
|
22
|
+
cb();
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
(err) => {
|
|
26
|
+
next(err, config, ctx);
|
|
27
|
+
}
|
|
28
|
+
);
|
|
25
29
|
});
|
|
26
30
|
|
|
27
31
|
function connect(connectionConfig, cb) {
|
|
28
|
-
debug(
|
|
32
|
+
debug("Connecting to broker using url: %s", connectionConfig.loggableUrl);
|
|
29
33
|
|
|
30
34
|
// See https://github.com/guidesmiths/rascal/issues/17
|
|
31
35
|
const once = _.once(cb);
|
|
32
36
|
let invocations = 0;
|
|
33
37
|
|
|
34
|
-
amqplib.connect(
|
|
38
|
+
amqplib.connect(
|
|
39
|
+
connectionConfig.url,
|
|
40
|
+
connectionConfig.socketOptions,
|
|
41
|
+
(err, connection) => {
|
|
42
|
+
invocations++;
|
|
35
43
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
if (err) {
|
|
45
|
+
const betterMessage = format(
|
|
46
|
+
"Failed to connect to: %s. Original message was:",
|
|
47
|
+
connectionConfig.loggableUrl,
|
|
48
|
+
err.message
|
|
49
|
+
);
|
|
50
|
+
err.message = betterMessage;
|
|
51
|
+
return once(err);
|
|
52
|
+
}
|
|
43
53
|
|
|
44
|
-
|
|
45
|
-
|
|
54
|
+
connection._rascal_id = uuid();
|
|
55
|
+
debug("Obtained connection: %s", connection._rascal_id);
|
|
46
56
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
/*
|
|
58
|
+
* If an error occurs during initialisation (e.g. if checkExchanges fails),
|
|
59
|
+
* and no error handler has been bound to the connection, then the error will bubble up
|
|
60
|
+
* to the UncaughtException handler, potentially crashing the node process.
|
|
61
|
+
*
|
|
62
|
+
* By adding an error handler now, we ensure that instead of being emitted as events
|
|
63
|
+
* errors will be passed via the callback chain, so they can still be handled by the caller
|
|
64
|
+
*
|
|
65
|
+
* This error handle is removed in the vhost after the initialiation has complete
|
|
66
|
+
*/
|
|
67
|
+
connection.on("error", (err) => {
|
|
68
|
+
debug(
|
|
69
|
+
"Received error: %s from %s",
|
|
70
|
+
err.message,
|
|
71
|
+
connectionConfig.loggableUrl
|
|
72
|
+
);
|
|
73
|
+
once(err);
|
|
74
|
+
});
|
|
61
75
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
76
|
+
// See https://github.com/squaremo/amqp.node/issues/388
|
|
77
|
+
if (invocations > 1) {
|
|
78
|
+
debug(
|
|
79
|
+
"Closing superfluous connection: %s previously reported as errored",
|
|
80
|
+
connection._rascal_id
|
|
81
|
+
);
|
|
82
|
+
return connection.close();
|
|
83
|
+
}
|
|
67
84
|
|
|
68
|
-
|
|
85
|
+
connection.setMaxListeners(0);
|
|
69
86
|
|
|
70
|
-
|
|
71
|
-
|
|
87
|
+
once(null, connection);
|
|
88
|
+
}
|
|
89
|
+
);
|
|
72
90
|
}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
const debug = require(
|
|
2
|
-
const _ = require(
|
|
3
|
-
const async = require(
|
|
1
|
+
const debug = require("debug")("rascal:tasks:deleteExchanges");
|
|
2
|
+
const _ = require("lodash");
|
|
3
|
+
const async = require("async");
|
|
4
4
|
|
|
5
5
|
module.exports = _.curry((config, ctx, next) => {
|
|
6
|
-
async.eachSeries(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
async.eachSeries(
|
|
7
|
+
_.keys(config.exchanges),
|
|
8
|
+
(name, callback) => {
|
|
9
|
+
deleteExchange(ctx.channel, config.exchanges[name], callback);
|
|
10
|
+
},
|
|
11
|
+
(err) => {
|
|
12
|
+
next(err, config, ctx);
|
|
13
|
+
}
|
|
14
|
+
);
|
|
11
15
|
});
|
|
12
16
|
|
|
13
17
|
function deleteExchange(channel, config, next) {
|
|
14
|
-
if (config.fullyQualifiedName ===
|
|
15
|
-
debug(
|
|
18
|
+
if (config.fullyQualifiedName === "") return next();
|
|
19
|
+
debug("Deleting exchange: %s", config.fullyQualifiedName);
|
|
16
20
|
channel.deleteExchange(config.fullyQualifiedName, {}, next);
|
|
17
21
|
}
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
const debug = require(
|
|
2
|
-
const _ = require(
|
|
3
|
-
const async = require(
|
|
1
|
+
const debug = require("debug")("rascal:tasks:deleteQueues");
|
|
2
|
+
const _ = require("lodash");
|
|
3
|
+
const async = require("async");
|
|
4
4
|
|
|
5
5
|
module.exports = _.curry((config, ctx, next) => {
|
|
6
|
-
async.eachSeries(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
async.eachSeries(
|
|
7
|
+
_.keys(config.queues),
|
|
8
|
+
(name, callback) => {
|
|
9
|
+
deleteQueue(ctx.channel, config.queues[name], callback);
|
|
10
|
+
},
|
|
11
|
+
(err) => {
|
|
12
|
+
next(err, config, ctx);
|
|
13
|
+
}
|
|
14
|
+
);
|
|
11
15
|
});
|
|
12
16
|
|
|
13
17
|
function deleteQueue(channel, config, next) {
|
|
14
|
-
debug(
|
|
18
|
+
debug("Deleting queue: %s", config.fullyQualifiedName);
|
|
15
19
|
channel.deleteQueue(config.fullyQualifiedName, {}, next);
|
|
16
20
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const debug = require(
|
|
2
|
-
const _ = require(
|
|
3
|
-
const async = require(
|
|
4
|
-
const client = require(
|
|
1
|
+
const debug = require("debug")("rascal:tasks:deleteVhost");
|
|
2
|
+
const _ = require("lodash");
|
|
3
|
+
const async = require("async");
|
|
4
|
+
const client = require("../../management/client");
|
|
5
5
|
|
|
6
6
|
module.exports = _.curry((config, ctx, next) => {
|
|
7
7
|
const vhostConfig = config.vhosts[ctx.vhost.name];
|
|
@@ -9,17 +9,26 @@ module.exports = _.curry((config, ctx, next) => {
|
|
|
9
9
|
|
|
10
10
|
const candidates = vhostConfig.connections;
|
|
11
11
|
|
|
12
|
-
async.retry(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
12
|
+
async.retry(
|
|
13
|
+
candidates.length,
|
|
14
|
+
(cb) => {
|
|
15
|
+
const connectionConfig = candidates[ctx.vhost.connectionIndex];
|
|
16
|
+
client.deleteVhost(
|
|
17
|
+
vhostConfig.name,
|
|
18
|
+
connectionConfig.management,
|
|
19
|
+
(err) => {
|
|
20
|
+
if (err) {
|
|
21
|
+
ctx.vhost.connectionIndex =
|
|
22
|
+
(ctx.vhost.connectionIndex + 1) % candidates.length;
|
|
23
|
+
return cb(err);
|
|
24
|
+
}
|
|
25
|
+
ctx.connectionConfig = connectionConfig;
|
|
26
|
+
cb();
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
},
|
|
30
|
+
(err) => {
|
|
31
|
+
next(err, config, ctx);
|
|
32
|
+
}
|
|
33
|
+
);
|
|
25
34
|
});
|