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