diff --git a/.eslintrc.json b/.eslintrc.json index 20b0a09..dbc8a5e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -16,7 +16,9 @@ "describe": true, "it": true, "before": true, + "beforeEach": true, "after": true, + "afterEach": true, "Promise": true }, "overrides": [ diff --git a/BatchQueueWorker.js b/BatchQueueWorker.js index 87af597..adff442 100644 --- a/BatchQueueWorker.js +++ b/BatchQueueWorker.js @@ -10,49 +10,59 @@ class BatchQueueWorker extends QueueWorker { constructor(app, options) { + if (!options) { + throw new Error('BatchQueueWorker: options are required'); + } + const batchSize = options.batchSize || 5; + const skipInit = options.skipInit || false; - // Set our base queue worker options based on our batch size - options.queueSubscriptionOptions = { ack: true, prefetchCount: batchSize }; + // Set the base QueueWorker options based on the given batch size + options.queueSubscriptionOptions = options.queueSubscriptionOptions || {}; + options.queueSubscriptionOptions.prefetch = batchSize * 2; + options.queueSubscriptionOptions.retry = options.queueSubscriptionOptions.retry || { delay: 1000 }; // Don't initialize until we're all setup options.skipInit = true; - // Start the engines + // Initialize underlying QueueWorker super(app, options); /** * Message batch size - How many messages we'll be sent at a time * @type {number} */ - this.batchSize = options.batchSize || 5; - this._isProcessing = null; // Not applicable to this worker + this.batchSize = batchSize; // Get the aggregator setup this._setupCargo(); // Start accepting messages - this.init(); + if (!skipInit) { + this.init(); + } } - /* istanbul ignore next: must be implemented or this does nothing */ //noinspection JSMethodCanBeStatic /** * This is the batch handler you need to override! * * @param {[*]} messages – Array of message objects, NOT payloads, that would be messages[0].message - * @param {function(requeueMessages:[], rejectMessages:[])} callback - Fire when done processing the batch + * @param {function(err:*=null, recovery:*=null)} defaultAckOrNack - Fire when done processing the batch */ - handleMessageBatch(messages, callback) { + handleMessageBatch(messages, defaultAckOrNack) { // YOU MUST IMPLEMENT THIS TO BE USEFUL - // DO NOT MANIPULATE `messages` !! IF YOU DO, YOU'll PROBABLY BREAK IT HARD - // e.g. DO NOT messages.pop/push/slice/splice, etc. THIS IS BAD. + // individually ack or nack a message in the batch + // messages[i].ackOrNack(); // individually ack or nack a message in the batch - // callback(requeueMessages, rejectMessages) - callback(messages, []); + // ack or nack the unhandled messages in the batch + // defaultAckOrNack(); // ack all + // defaultAckOrNack(err); // err all w/ default strategy + // defaultAckOrNack(err, recovery); // err all w/ specific strategy + defaultAckOrNack(true, this.nack.drop); // err all w/ drop strategy } /** @@ -60,131 +70,64 @@ class BatchQueueWorker extends QueueWorker { * @private */ _setupCargo() { - this._cargo = Async.cargo(this._processCargoBatch.bind(this)); + this._cargo = Async.cargo(this._processCargoBatch.bind(this), this.batchSize); } /** * Internal handler for shipping a batch of messages to the application - * @param messages + * @param {[CargoMessage]} messages * @param callback * @private */ _processCargoBatch(messages, callback) { - // Hold onto the last message in case we get to accept the entire batch - const lastMessage = messages[messages.length-1]; - // Pass the batch to the handler - this.handleMessageBatch(messages, (requeue, reject) => { - - // Normalize responses if they're empty - requeue = Array.isArray(requeue) ? requeue : []; - reject = Array.isArray(reject) ? reject : []; - - // If there's anything to throw away - if (requeue.length + reject.length > 0) { - - // Iterate each and accept, or reject/requeue - messages.forEach((message) => { - if (requeue.includes(message)) { - message.messageObject.reject(true); - } else if (reject.includes(message)) { - message.messageObject.reject(false); - } else { - message.messageObject.acknowledge(false); - } - }); - - } else { - // Ack the entire batch - lastMessage.messageObject.acknowledge(true); - } + this.handleMessageBatch(messages, (err, recovery) => { + + // Ack/Nack any unhandled message + messages.forEach((message) => { + if (!message._handled) { + message.ackOrNack(err, recovery); + } + }); callback(); }); } /** - * Override the default message handler system - * - * @see https://github.com/postwait/node-amqp#queuesubscribeoptions-listener + * Override the default message handler system. Routes messages into async cargo. * - * @param message - Message body - * @param [headers] - Message headers - * @param [deliveryInfo] - Raw message info - * @param [messageObject] - Message object wrapper (e.g. messageObject.acknowedge(false) ) + * @param message - Message object + * @param content – Message body + * @param ackOrNack – Callback to ack or nack the message */ - onMessage(message, headers, deliveryInfo, messageObject) { - /* istanbul ignore else: I really tried to unit test this but i don't think i can (timing) */ - if (!this._isShuttingDown) { - - // Queue this into the current batch - this._cargo.push({ - message, - headers, - deliveryInfo, - messageObject - }); - - } else { - // If we're in the process of shutting down, reject+requeue this message so it's handled later - setImmediate(() => messageObject.reject(true)); - } - } + onMessage(message, content, ackOrNack) { - /* istanbul ignore next: not implemented in this class */ - /** - * Callback provided to the message handler to complete working with the message - * @param reject - * @param requeue - */ - onMessageHandled(reject, requeue) { /* eslint-disable-line no-unused-vars */ - throw new Error('This method does not apply to this worker. Do not use it.'); - } + /** + * Wrapped Cargo Message + * @typedef {{message: *, content: *, ackOrNack: function(err:*,recovery:*), _handled: boolean}} CargoMessage + */ + const payload = { + message, + content, + // wrapper around given ackOrNack, if message individually handled, flag it + ackOrNack: (...params) => { + payload._handled = true; + ackOrNack.apply(null, params); + }, + _handled: false + }; - /* istanbul ignore next: not implemented in this class */ - /** - * Hook point for handling messages - * - * @see https://github.com/postwait/node-amqp#queuesubscribeoptions-listener - * - * @param message - Message body - * @param {function(reject:boolean, requeue:boolean)} callback - Fire when done processing the message - * @param [headers] - Message headers - * @param [deliveryInfo] - Raw message info - * @param [messageObject] - Message object wrapper (e.g. messageObject.acknowedge(false) ) - */ - handleMessage(message, callback, headers, deliveryInfo, messageObject) { /* eslint-disable-line no-unused-vars */ - throw new Error('This method does not apply to this worker. Do not use it.'); + // Queue this into the current batch + this._cargo.push(payload); } - //noinspection JSUnusedGlobalSymbols,JSUnusedLocalSymbols /** - * Starts the internal shutdown process (hook point) + * Do not use this method on this QueueWorker */ - prepareForShutdown(canAsync) { /* eslint-disable-line no-unused-vars */ - - this.log(` !! Shutting down the ${this.queueName} queue`); - - // Flag that we're shutting down - this._isShuttingDown = true; - - // Unsub and shutdown - const done = () => { - this.unsubscribe(() => { - this.shutdown(); - }); - }; - - // If the cargo is still working, then drain it and end, otherwise just end - /* istanbul ignore next: it's really hard to test this case of cargo still got junk in it at shutdown */ - if (this._cargo.length() > 0) { - this._cargo.drain = () => { - done(); - }; - } else { - done(); - } + handleMessage(message, content, ackOrNack) { /* eslint-disable-line no-unused-vars */ + throw new Error('BatchQueueWorker: This method does not apply to this worker. Do not use it.'); } } diff --git a/QueueService.js b/QueueService.js index 669c75e..9d0e6f9 100644 --- a/QueueService.js +++ b/QueueService.js @@ -1,7 +1,6 @@ "use strict"; -const AMQP = require('amqp'); -const Async = require('async'); +const Rascal = require('rascal'); /** * Okanjo Message Queue Service @@ -13,64 +12,45 @@ class QueueService { * Queue management service * @param {OkanjoApp} app * @param {*} [config] service config - * @param {*} [queues] - Queue enumeration * @constructor */ - constructor(app, config, queues) { + constructor(app, config) { this.app = app; - this.config = config || app.config.rabbit; + this.config = config; - if (!this.config) { - throw new Error('okanjo-app-queue: No configuration set for QueueService!'); + if (!this.config || !this.config.rascal) { + throw new Error('okanjo-app-queue: No rascal configuration set for QueueService!'); } - this.queues = queues || this.config.queues || {}; - this.reconnect = true; - - this.rabbit = null; - this.activeExchanges = {}; - this.activeQueues = {}; + this.broker = null; // set on connect // Register the connection with the app - app._serviceConnectors.push((cb) => { - - this.connect(() => { - /* istanbul ignore else: too hard to edge case this with unit tests and docker */ - if (cb) { - cb(); - } - cb = null; // don't do this twice - }); - + app._serviceConnectors.push(async () => { + await this.connect(); }); } /** * Connects to RabbitMQ and binds the necessary exchanges and queues - * @param callback - Fired when connected and ready to publish messages */ - connect(callback) { - - // Create the rabbit connection - this.rabbit = AMQP.createConnection(this.config); - - // Internally, amqp uses it's own error listener, so the default of 10 is not sufficient - this.rabbit.setMaxListeners(50); - - // Bind events - this.rabbit - .on('error', this._handleConnectionError.bind(this)) - .on('end', this._handleConnectionEnd.bind(this)) - .on('ready', this._handleConnectionReady.bind(this, callback)); + async connect() { + try { + this.broker = await Rascal.BrokerAsPromised.create(Rascal.withDefaultConfig(this.config.rascal)); + this.broker.on('error', this._handleBrokerError.bind(this)); + } catch(err) { + this.app.report('okanjo-app-queue: Failed to create Rascal broker:', err); + throw err; + } } /** * Publishes a message to the given queue - * @param queue - The queue name to publish to - * @param data - The message data to queue + * @param {string} queue - The queue name to publish to + * @param {*} data - The message data to queue * @param [options] - The message data to queue * @param [callback] - Fired when done + * @returns {Promise} */ publishMessage(queue, data, options, callback) { @@ -80,110 +60,25 @@ class QueueService { options = {}; } - // If options was given but has no value, default it to an empty object - // options = options || {}; + return new Promise(async (resolve, reject) => { + let pub; + try { + pub = await this.broker.publish(queue, data, options); + } catch (err) { + this.app.report('okanjo-app-queue: Failed to publish queue message', err, { queue, data, options }); - this.activeExchanges[queue].publish('', data, options, (hasError, err) => { - /* istanbul ignore if: edge case testing with rabbit isn't necessary yet */ - if (hasError) { - this.app.report('Failed to publish queue message', err, data, queue); + if (callback) return callback(err); + return reject(err); } - /* istanbul ignore else: i'm confident that this is solid, unit tests need the ack so good enough for now */ - if (callback) { - // Use next tick to clear i/o on the event loop if someone's planning on batch queuing - setImmediate(() => callback(err)); - } + if (callback) return callback(null, pub); + return resolve(pub); }); - } - /* istanbul ignore next: would require edge casing docker connection states */ - /** - * Handles a connection error event from RabbitMQ - * @param err - Error received - * @private - */ - _handleConnectionError(err) { - if (err !== 'RECONNECT PLZ') { - this.app.report('RabbitMQ connection error!', err); - } } - /* istanbul ignore next: would require edge casing docker connection states */ - /** - * Handles a connection closed event from RabbitMQ - * @private - */ - _handleConnectionEnd() { - if (this.reconnect) { - // Manually trigger an error to use the built in reconnection functionality - process.nextTick(this.rabbit.emit.bind(this.rabbit, 'error', 'RECONNECT PLZ')); - } - } - - /** - * Handles a connection ready event from RabbitMQ - * @param callback - Fired when done - * @private - */ - _handleConnectionReady(callback) { - - // Bind the exchanges and queues! - Async.each( - Object.keys(this.queues), - (key, next) => { - this._bindQueueExchange(this.queues[key], next); - }, - (err) => { - process.nextTick(callback.bind(null, err)); - callback = null; // Don't fire again on reconnects - } - ); - } - - /** - * Binds an exchange and a queue with the given name - * @param name - The name to use - * @param callback - Fired when done - * @private - */ - _bindQueueExchange(name, callback) { - // Note: exchange and queue share the same name - // Connect to the exchange - this.rabbit.exchange(name, { - type: 'direct', - durable: true, - autoDelete: false, - confirm: true - }, (exchange) => { - - // Save this for later because we'll need it to send of messages to report - this.activeExchanges[name] = exchange; - - // Connect to the queue - this.rabbit.queue(name, { - exclusive: false, - durable: true, - autoDelete: false - }, (queue) => { - - // Save the queue so we can gracefully unsubscribe later - this.activeQueues[name] = queue; - - // Bind and subscribe to the queue - queue.bind(name, ''); - - //console.error(' >> Message queue connected:', name); - - /* istanbul ignore else: would require edge casing docker connection states */ - // Queue bound and ready to rock and roll - if (callback) { - process.nextTick(callback.bind()); - callback = null; - } - - }); // - }); // + _handleBrokerError(err) { + this.app.report('okanjo-app-queue: Rascal Broker error', err); } } @@ -199,4 +94,34 @@ QueueService.QueueWorker = require('./QueueWorker'); */ QueueService.BatchQueueWorker = require('./BatchQueueWorker'); +/** + * Helper to generate a vhost config for Rascal based on old queue-name only setup + * @param queueNames – Array of string queue names + * @param [config] – Optional vhost config to append to + * @returns {*|{exchanges: Array, queues: {}, bindings: {}, subscriptions: {}, publications: {}}} + */ +QueueService.generateConfigFromQueueNames = (queueNames, config) => { + config = config || {}; + config.exchanges = config.exchanges || []; + config.queues = config.queues || {}; + config.bindings = config.bindings || {}; + config.subscriptions = config.subscriptions || {}; + config.publications = config.publications || {}; + + queueNames.forEach((name) => { + config.exchanges.push(name); + config.queues[name] = {}; + config.bindings[name] = { + source: name, + destination: name, + destinationType: "queue", + bindingKey: "" // typically defaults to #, does this matter? + }; + config.subscriptions[name] = { queue: name }; + config.publications[name] = { exchange: name }; + }); + + return config; +}; + module.exports = QueueService; \ No newline at end of file diff --git a/QueueWorker.js b/QueueWorker.js index fc622a5..4011bd8 100644 --- a/QueueWorker.js +++ b/QueueWorker.js @@ -1,7 +1,6 @@ "use strict"; const OkanjoWorker = require('okanjo-app-broker/OkanjoWorker'); -const Async = require('async'); /** * Base worker for dealing with message queue processing @@ -17,8 +16,12 @@ class QueueWorker extends OkanjoWorker { constructor(app, options) { // We cannot start unless we have a queue name - if (!options.queueName) { - throw new Error('Missing require option: queueName'); + if (!options.subscriptionName) { + throw new Error('Missing required option: subscriptionName'); + } + + if (!options.service) { + throw new Error('Missing required option: service'); } // Init the base worker here @@ -28,19 +31,25 @@ class QueueWorker extends OkanjoWorker { * The queue service to use to talk to rabbit * @type {QueueService} */ - this.service = options.service || app.services.queue; // Default to app.services.queue if none was given + this.service = options.service; /** * The name of the queue to consume * @type {string} */ - this.queueName = options.queueName; // <-- Override this before starting up! + this.subscriptionName = options.subscriptionName; // <-- Override this before starting up! + + + const defaultSubscriberOptions = { + prefetch: 1, + retry: { delay: 1000 } // Retries after a one second interval. + }; /** * Queue consumer settings - Require confirmation and process one at a time - * @type {{ack: boolean, prefetchCount: number}} + * @type {*|{prefetch: number, retry: {delay: number}}|queueSubscriptionOptions|{prefetch, retry}} */ - this.queueSubscriptionOptions = options.queueSubscriptionOptions || { ack: true, prefetchCount: 1 }; + this.queueSubscriptionOptions = options.queueSubscriptionOptions || defaultSubscriberOptions; /** * Status var to keep track of whether the worker is currently able to consume messages from the queue @@ -49,50 +58,34 @@ class QueueWorker extends OkanjoWorker { this._isSubscribed = false; /** - * Flag that prevents processing messages while transitioning - * @type {boolean} - * @private - */ - this._isShuttingDown = false; - - /** - * Flag that indicates whether a message or batch is being handled + * Whether to make noise to the console * @type {boolean} - * @private - */ - this._isProcessing = false; - - /** - * When subscribed, hold a reference to the consumer tag id so we can gracefully un-subscribe on shutdown - * @type {null} - * @private */ - this._consumerTag = null; + this.verbose = options.verbose === undefined ? true : options.verbose; - /** - * Whether an error was emitted and a subscribe attempt is in progress - * @type {boolean} - * @private - */ - this._recovering = false; + // ackOrNack(err, { strategy: 'nack' }) // DISCARD MESSAGE or DEAD LETTER IT + // ackOrNack(err, { strategy: 'nack', defer: 1000, requeue: true }) // REJECT and REQUEUE (top of queue) + // ackOrNack(err, { strategy: 'republish', defer: 1000 }) // REJECT and REQUEUE (bottom of queue) /** - * If dup errors are thrown, fire these callbacks when an attempt finishes - * @type {Array} - * @private + * Message rejection strategies + * @type {{drop: {strategy: string}, requeue: {strategy: string, defer: number, requeue: boolean}, republish: {strategy: string, defer: number}}} */ - this._recoverHooks = []; + this.nack = { + drop: { strategy: 'nack' }, // discard message or dead-letter it + requeue: { strategy: 'nack', defer: 1000, requeue: true }, // reject + requeue (old functionality) + republish: { strategy: 'republish', defer: 1000 } // reject + republish to queue + }; - /* istanbul ignore next: Not interested in verbosity tests */ /** - * Whether to make noise to the console - * @type {boolean} + * Default error nack strategy + * @type {{strategy: string, defer: number}|QueueWorker.nack.republish|{strategy, defer}} */ - this.verbose = options.verbose === undefined ? true : options.verbose; + this.nack.default = this.nack.republish; - // Bind copies of the handlers so we can scrap the event listener later - this.onServiceError = this.onServiceError.bind(this); - this._handleTagChangeEvent = this._handleTagChangeEvent.bind(this); + // Changeable defaults for error handlers + this.nack._redeliveriesExceeded = this.nack.default; + this.nack._invalidContent = this.nack.default; // Initialize now if (!options.skipInit) { @@ -106,7 +99,6 @@ class QueueWorker extends OkanjoWorker { * @param message */ log(message) { - /* istanbul ignore else: Not interested in verbosity tests */ if (this.verbose) this.app.log(message); } @@ -114,251 +106,144 @@ class QueueWorker extends OkanjoWorker { /** * Subscribe and consume queue messages */ - init(callback) { + async init() { // Set the reporting context - this.app.setReportingContext({ worker: this.queueName }); + this.app.setReportingContext({ worker: this.subscriptionName }); // Connect to the basic app services - this.app.connectToServices(this.onReady.bind(this, callback)); + await this.app.connectToServices(async () => { + await this.subscribe(); + }); } /** - * Fired when the app is ready for use - Starts the queue subscription process - * @param callback + * Subscribe to the queue */ - onReady(callback) { - // Keep a reference to the queue object for use locally - this.queue = this.service.activeQueues[this.queueName]; + async subscribe() { - // Bind our own error handler - this.service.rabbit.on('error', this.onServiceError); - - // When a reconnection occurs, and our consumer is replaced, we should probably find out about that, right? - this.service.rabbit.on('tag.change', this._handleTagChangeEvent); + // Don't sub over an existing subscription + if (this.subscription) { + const err = new Error('QueueWorker: Already subscribed!'); + await this.app.report(err.message, err, { subscription: this.subscriptionName, options: this.queueSubscriptionOptions }); + throw err; + } - // Do it - this.subscribe(callback); + try { + this.subscription = await this.service.broker.subscribe(this.subscriptionName, this.queueSubscriptionOptions); + this.subscription.on('error', this.onSubscriptionError.bind(this)); + this.subscription.on('invalid_content', this.onInvalidContent.bind(this)); + this.subscription.on('redeliveries_exceeded', this.onRedeliveriesExceeded.bind(this)); + this.subscription.on('message', this.onMessage.bind(this)); + this.onSubscribed(); + } catch (err) { + await this.app.report('QueueWorker: Failed to subscribe to queue', err, { subscription: this.subscriptionName, options: this.queueSubscriptionOptions }); + throw err; + } } + // ackOrNack(err, { strategy: 'nack' }) // DISCARD MESSAGE or DEAD LETTER IT + // ackOrNack(err, { strategy: 'nack', defer: 1000, requeue: true }) // REJECT and REQUEUE (top of queue) + // ackOrNack(err, { strategy: 'republish', defer: 1000 }) // REJECT and REQUEUE (bottom of queue) + /** - * Handles the event when a reconnection occurs, and our consumer is replaced, - * we should probably find out about that, right? - * @param event - * @private + * Occurs when the message was redelivered too many times or there was a message error + * @param err + * @param message + * @param ackOrNack */ - _handleTagChangeEvent(event) { - /* istanbul ignore else: not my consumer, not my problem, that's what i say */ - if (this._consumerTag === event.oldConsumerTag) { - // noinspection JSUnusedGlobalSymbols - this._consumerTag = event.consumerTag; - this._unsubscribe(event.oldConsumerTag, () => { - this.log(`!! Consumer tag for queue ${this.queueName} changed`); - }); // eat the error if any, that tag is dead to us anyway - } + onRedeliveriesExceeded(err, message, ackOrNack) { + this.app.report('QueueWorker: Re-deliveries exceeded on message', err, { subscription: this.subscriptionName, message }).then(() => { + ackOrNack(err, this.nack._redeliveriesExceeded); + }); } /** - * Fired when the queue has been subscribed to - Stores reference info about the subscription - * @param callback - * @param res - The queue subscription result + * Occurs when the message content could not be parsed or there was a message error + * @param err + * @param message + * @param ackOrNack */ - onSubscribed(callback, res) { - this.log(` > Subscribed to the ${this.queueName} queue`); - this._isSubscribed = true; - // noinspection JSUnusedGlobalSymbols - this._consumerTag = res.consumerTag; - - // Notify anyone who's waiting for the subscriber to finish - if (callback) callback(); + onInvalidContent(err, message, ackOrNack) { + this.app.report('QueueWorker: Invalid content received', err, { subscription: this.subscriptionName, message }).then(() => { + ackOrNack(err, this.nack._invalidContent); + }); } /** - * Fired when the consumer has unsubscribed from the queue - * @param [callback] - Fired when done handling the event - * //@param {{consumerTag:string}} res + * Occurs when the subscriber has an error + * @param err */ - onUnsubscribed(callback/*, res*/) { - // Flag that we are no longer subscribed - this._isSubscribed = false; - - // Console audit - this.log(` > Unsubscribed from the ${this.queueName} queue`); - - // Notify that we're done - /* istanbul ignore else: this works, ok? */ - if (callback) callback(); + onSubscriptionError(err) { + // noinspection JSIgnoredPromiseFromCall + this.app.report('QueueWorker: Subscription error', err, { subscription: this.subscriptionName }); } /** - * First line of handling a message received from the queue - deals with connection states - * - * @see https://github.com/postwait/node-amqp#queuesubscribeoptions-listener - * - * @param message - Message body - * @param [headers] - Message headers - * @param [deliveryInfo] - Raw message info - * @param [messageObject] - Message object wrapper (e.g. messageObject.acknowedge(false) ) + * Unsubscribes from the queue if able to do so */ - onMessage(message, /* you might not care about the rest of these params */ headers, deliveryInfo, messageObject) { - /* istanbul ignore else: I really tried to unit test this but i don't think i can (timing) */ - if (!this._isShuttingDown) { - - // Pass the message to the handler - this._isProcessing = true; - this.handleMessage(message, this.onMessageHandled.bind(this), headers, deliveryInfo, messageObject); + async unsubscribe() { + if (this._isSubscribed && this.subscription) { + try{ + await this.subscription.cancel(); + } catch(err) /* istanbul ignore next: out of scope */ { + await this.app.report('QueueWorker: Failed to unsubscribe', err, { subscription: this.subscriptionName }); + } + this.onUnsubscribed(); + } + } - } else { - // If we're in the process of shutting down, reject this message so it's handled later - setImmediate(this.queue.shift.bind(this.queue, true, true)); - } + /** + * Fired when the queue has been subscribed to - Stores reference info about the subscription + */ + onSubscribed() { + this.log(` > Subscribed to the ${this.subscriptionName} queue`); + // noinspection JSUnusedGlobalSymbols + this._isSubscribed = true; } /** - * Callback provided to the message handler to complete working with the message - * @param reject - * @param requeue + * Fired when the consumer has unsubscribed from the queue */ - onMessageHandled(reject, requeue) { - if (reject) { - // Delay a reject so we don't lock the app up with constantly retrying failures - setTimeout(() => { - this.queue.shift(reject, requeue); - this._isProcessing = false; - }, 1000); - } else { - this.queue.shift(reject, requeue); - this._isProcessing = false; - } + onUnsubscribed() { + // Flag that we are no longer subscribed + // noinspection JSUnusedGlobalSymbols + this._isSubscribed = false; + this.subscription = null; + // Console audit + this.log(` > Unsubscribed from the ${this.subscriptionName} queue`); } /** - * Handle connection errors, hopefully recover message consumption - * @param connectionErr + * First line of handling a message received from the queue - deals with connection states + * + * @param message - Message object + * @param content – Message body + * @param ackOrNack – Callback to ack or nack the message */ - onServiceError(connectionErr) { - if (this._recovering) { - // Wait until the attempt is done - /* istanbul ignore next: out of scope */ - this._recoverHooks.push((err) => { - if (err) { - // Failed to reconnect, try again - setImmediate(() => this.onServiceError(connectionErr)); - } - }); - } else { - // noinspection JSUnusedGlobalSymbols - this._recovering = true; - - // Our connection was probably lost (ETIMEDOUT) but we're not going to resubscribe automatically, so let's do that. - const originalTag = this._consumerTag; - this.unsubscribe((unsubscribeErr) => { - - - // There's a chance that auto-recovery will replace our channel, so we don't need to dup another consumer here - /* istanbul ignore if: reconnection *should* restablish the link and update the tag, so this shouldn't need to happen, but if it does, then this should take care of it */ - if (this._consumerTag === originalTag) { - this.subscribe((subscribeErr) => { - - /* istanbul ignore if: out of scope */ - if (subscribeErr) { - this.app.report('Failed to recover consumer subscription when rabbit connection error occurred', { - subscribeErr, - unsubscribeErr, - connectionErr - }); - } - - // Handle duplicate errors while recovery was in progress - // noinspection JSUnusedGlobalSymbols - this._recovering = false; - this._recoverHooks.forEach((hook) => hook(subscribeErr)); - }); - } else { - // Our consumer was replaced, so we're all done - this._isSubscribed = true; - // noinspection JSUnusedGlobalSymbols - this._recovering = false; - this._recoverHooks.forEach((hook) => hook()); - } - - }); - } + onMessage(message, content, ackOrNack) { + // Pass the message to the handler + this.handleMessage(message, content, ackOrNack); } /* istanbul ignore next: This function must be overridden to be useful */ /** * Hook point for handling messages - * - * @see https://github.com/postwait/node-amqp#queuesubscribeoptions-listener - * - * @param message - Message body - * @param {function(reject:boolean, requeue:boolean)} callback - Fire when done processing the message - * @param [headers] - Message headers - * @param [deliveryInfo] - Raw message info - * @param [messageObject] - Message object wrapper (e.g. messageObject.acknowedge(false) ) + * @param message + * @param content + * @param ackOrNack */ - handleMessage(message, callback, headers, deliveryInfo, messageObject) { + handleMessage(message, content, ackOrNack) { // TODO - this is the hook point where you handle the message - // When reject is true, the message will be put back on the queue IF requeue is true, otherwise it'll be discarded - const reject = true; - const requeue = true; // only matters if reject is true - - this.app.inspect('Received queue message', this.queueName, message, headers, deliveryInfo, messageObject); + this.app.dump('Received queue message', { subscription: this.subscriptionName, message, content }); // When finished handling the message, accept it or reject it - callback(reject, requeue); - } - - /** - * Subscribe to the queue - * @param callback - */ - subscribe(callback) { - - // Subscribe to the queue - this.queue - .subscribe(this.queueSubscriptionOptions, this.onMessage.bind(this)) - .addCallback(this.onSubscribed.bind(this, callback)); - - } - - /** - * Unsubscribes from the queue if able to do so - * @param callback - */ - unsubscribe(callback) { - // Only unsubscribe if actively connected - if (this._consumerTag && this._isSubscribed) { - this._unsubscribe(this._consumerTag, this.onUnsubscribed.bind(this, callback)); - } else { - /* istanbul ignore else: you really need to send a callback */ - if (callback) callback(); - } - } - - /** - * Unsubscribes from the given consumer - * @param tag - * @param callback - * @private - */ - _unsubscribe(tag, callback) { - this.queue - .unsubscribe(tag) - .addCallback(callback); - } - - /** - * Removes hooks on the rabbit service - * @private - */ - _dropListeners() { - this.service.rabbit.removeListener('error', this.onServiceError); - this.service.rabbit.removeListener('tag.change', this._handleTagChangeEvent); + // ackOrNack() // accept + // ackOrNack(err, recovery); // reject, with recovery method + ackOrNack(true, this.nack.republish); } //noinspection JSUnusedGlobalSymbols,JSUnusedLocalSymbols @@ -367,36 +252,17 @@ class QueueWorker extends OkanjoWorker { */ prepareForShutdown(canAsync) { /* eslint-disable-line no-unused-vars */ - this.log(` !! Shutting down the ${this.queueName} queue`); - - // Flag that we're shutting down - this._isShuttingDown = true; - - // If there's a message in the works, wait for it to end - Async.retry( - { times: 10, interval: 200 }, - (cb) => { - if (this._isProcessing) { - cb('not ready'); - } else { - cb(null, 'ready'); - } - }, - () => { - // Un-subscribe if able to do so - this.unsubscribe(() => { - this.shutdown(); + this.log(` !! Shutting down the ${this.subscriptionName} queue`); + (async () => { + // If there's a message in the works, wait for it to end + try { + await this.service.broker.shutdown(); + } catch (err) { + await this.app.report('QueueWorker: Failed to shutdown broker', err, { + subscription: this.subscriptionName }); } - ); - - this._dropListeners(); - - // The train is leaving the station, with or without us. - /* istanbul ignore if: won't test the process abort scenario */ - //if (!canAsync) { - // this.shutdown(); - //} + })(); } } diff --git a/README.md b/README.md index 2c74f59..29f5aed 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ This package: * Provides message publishing and consumer functionality * Provides a worker class for one-at-a-time message consumption * Provides a worker class for batch message consumption -* Bundles a custom [node-amqp](https://github.com/kfitzgerald/node-amqp/tree/nack) dependency, since the main package is neglected. +* Uses [Rascal](https://github.com/guidesmiths/rascal) for the underlying queue configuration and interface. ## Installing @@ -22,6 +22,38 @@ npm install okanjo-app-queue Note: requires the [`okanjo-app`](https://github.com/okanjo/okanjo-app) module. +## Breaking Changes + +### v2.0.0 + + * Underlying driver has changed from forked-version of postwait's `amqp` to rascal/amqplib + * Queue configuration has changed, see Rascal's configuration scheme + * QueueService + * constructor no longer takes `queues` param, this is setup in the Rascal config + * `queues` property has been removed + * `connect` is now an async function (no more callback) + * many internal member functions have been removed + * QueueWorker + * constructor option `queueName` is now `subscriptionName` + * constructor requires option `service` (instance of QueueService) + * many internal members have been removed + * `init` is now an async function (no more callback) + * `subscribe` is now an async function (no more callback) + * `onReady` has been removed + * `onSubscribed` no longer has arguments + * `onUnsubscribed` no longer has arguments + * `onMessage` signature has changed to `(message, content, ackOrNack)` + * `onMessageHandled` has been removed + * `handleMessage` signature has changed to `(message, content, ackOrNack)` + * `onServiceError` has been removed + * BatchQueueWorker + * option `batchSize` now translates to a prefetch of (batchSize * 2), so Async.Cargo can optimally deliver the desired batch size to the app. + * `handleMessageBatch` has changed signature to (messages, defaultAckOrNack) + * Messages are wrapped, and can be individually acknowledged via `messages[i].ackOrNack(...)`. Likewise, `defaultAckOrNAck(...)` will handle the remaining messages in the batch. + * `onMessage` signature has changed to `(message, content, ackOrNack)` + * `onMessageHandled` has been removed + * `prepareForShutdown` override has been removed + ## Example Usage Here's an example app: @@ -45,24 +77,24 @@ class MyBatchWorker extends BatchQueueWorker { constructor(app) { super(app, { service: app.services.queue, - queueName: app.services.queue.queues.batch, + subscriptionName: app.config.rabbit.queues.batch, batchSize: 5 }); } - handleMessageBatch(messages, callback) { + handleMessageBatch(messages, defaultAckOrNack) { // FYI: messages will be an array of message objects, not message payloads // This worker will simply report the values of the messages it is processing - const values = messages.map((message) => message.message.my_message); + const values = messages.map((message) => message.content.my_message); console.log(`MyBatchWorker consumed messages: ${values.join(', ')}`); // ack all of the processed messages - callback([], []); + defaultAckOrNack(); // or you could reject/requeue them too: - // callback(requeueMessages, rejectMessages) + // defaultAckOrNack(err, recovery); } } @@ -81,20 +113,20 @@ class MyQueueWorker extends QueueWorker { constructor(app) { super(app, { service: app.services.queue, - queueName: app.services.queue.queues.events, + subscriptionName: app.config.rabbit.queues.events }); } - handleMessage(message, callback, headers, deliveryInfo, messageObject) { + handleMessage(message, content, ackOrNack) { // This worker will simply report the values of the messages it is processing - console.log(`MyQueueWorker consumed message: ${message.my_message}`); + console.log(`MyQueueWorker consumed message: ${content.my_message}`); // Ack the message - callback(false, false); + ackOrNack(); // or you could reject, requeue it - // callback(reject, requeue); + // ackOrNack(err, recovery); } } @@ -102,45 +134,55 @@ module.exports = MyQueueWorker; ``` ### `example-app/config.js` -Typical OkanjoApp configuration file, containing the queue service config +Typical OkanjoApp configuration file, containing the queue service config. Generates exchanges, queues, bindings, publications and subscriptions based only on the queue names. ```js "use strict"; // Ordinarily, you would set normally and not use environment variables, // but this is for ease of running the example across platforms -const host = process.env.RABBIT_HOST || '192.168.99.100'; +const hostname = process.env.RABBIT_HOST || 'localhost'; const port = process.env.RABBIT_PORT || 5672; -const login = process.env.RABBIT_USER || 'test'; -const password = process.env.RABBIT_PASS || 'test'; -const vhost = process.env.RABBIT_VHOST || 'test'; +const user = process.env.RABBIT_USER || 'guest'; +const password = process.env.RABBIT_PASS || 'guest'; +const vhost = process.env.RABBIT_VHOST || '/'; -module.exports = { - rabbit: { - host, - port, +const queues = { + events: "my_events", + batch: "my_batches" +}; - login, - password, +const generateConfigFromQueueNames = require('../../QueueService').generateConfigFromQueueNames; - vhost, - // What exchanges/queues to setup (they'll be configured to use the same name) - queues: { - events: "my_events", - batch: "my_batches" +module.exports = { + rabbit: { + rascal: { + vhosts: { + [vhost]: generateConfigFromQueueNames(Object.values(queues), { + connections: [ + { + hostname, + user, + password, + port, + options: { + heartbeat: 1 + }, + socketOptions: { + timeout: 1000 + } + } + ] + }) + } }, - // Handle connection drop scenarios - reconnect: true, - reconnectBackoffStrategy: 'linear', - reconnectBackoffTime: 1000, - reconnectExponentialLimit: 5000 // don't increase over 5s to reconnect + // What exchanges/queues to setup (they'll be configured to use the same name) + queues, } }; ``` -The configuration extends the [node-amqp](https://github.com/kfitzgerald/node-amqp/tree/nack#connection-options-and-url) configuration. See there for additional options. - ### `index.js` Example application that will connect, enqueue, and consume messages. Cluster is used to consume messages on forked processes, to keep the main process clean. ```js @@ -166,13 +208,13 @@ if (Cluster.isMaster) { const myQueueBroker = new OkanjoBroker(app, 'my_queue_worker'); // Start the main application - app.connectToServices(() => { + app.connectToServices().then(() => { // Everything connected, now we can send out some messages to our workers // You can use service.queues.key as an enumeration when working with queues - const batchQueueName = app.services.queue.queues.batch; - const regularQueueName = app.services.queue.queues.events; + const batchQueueName = app.config.rabbit.queues.batch; + const regularQueueName = app.config.rabbit.queues.events; // Send out a batch of messages to the batch queue Async.eachSeries( @@ -245,28 +287,22 @@ RabbitMQ management class. Must be instantiated to be used. ## Properties * `service.app` – (read-only) The OkanjoApp instance provided when constructed * `service.config` – (read-only) The queue service configuration provided when constructed -* `service.queues` – (read-only) The queues enumeration provided when constructed -* `service.reconnect` – Whether to reconnect when the connection terminates -* `service.rabbit` – (read-only) The underlying node-amqp connection -* `service.activeExchanges` – Map of active [exchanges](https://github.com/kfitzgerald/node-amqp/tree/nack#exchange), keyed on queue name -* `service.activeQueues` – Map of active [queues](https://github.com/kfitzgerald/node-amqp/tree/nack#queue) +* `service.broker` – (read-only) The underlying Rascal broker (promised) ## Methods -### `new QueueService(app, [config, [queues]])` +### `new QueueService(app, config)` Creates a new queue service instance. * `app` – The OkanjoApp instance to bind to -* `config` – (Optional) The queue service configuration object. Defaults to app.config.rabbit if not provided. - * The configuration extends the [node-amqp](https://github.com/kfitzgerald/node-amqp/tree/nack#connection-options-and-url) configuration. See there for additional options. - * `config.queues` – Enumeration of queue names. For example: `{ events: "my_event_queue_name" }` -* `queues` – (Optional) Enumeration of queue names. Overrides config.queues if both are set. Use this separately if you intend on using multiple service instances. For example: `{ events: "my_event_queue_name" }` +* `config` – The Rascal configuration object. See [Rascal](https://github.com/guidesmiths/rascal) ### `service.publishMessage(queue, data, [options], [callback])` -Publishes a message to a queue. -* `queue` – The name of the exchange/queue to publish to. +Publishes a message to a Rascal publication. +* `queue` – The name of the Rascal publication to send to * `data` – The object message to publish. -* `options` – (Optional) Additional [exchange options](https://github.com/kfitzgerald/node-amqp/tree/nack#exchangepublishroutingkey-message-options-callback), if needed. -* `callback(err)` – (Optional) Function to fire when message has been sent or failed to send. +* `options` – (Optional) Additional [publication options](https://github.com/guidesmiths/rascal#publications), if needed. +* `callback(err)` – (Optional) Function to fire when message has been sent or failed to send. +* Returns a promise. ## Events @@ -279,34 +315,37 @@ Base class for basic queue consumer applications. Must be extended to be useful. ## Properties * `worker.service` – (read-only) The QueueService instance provided when constructed -* `worker.queueName` – (read-only) The name of the queue the worker consumes -* `worker.queueSubscriptionOptions` – (read-only) The queue [subscribe options](https://github.com/kfitzgerald/node-amqp/tree/nack#queuesubscribeoptions-listener) to use when subscribing +* `worker.subscriptionName` – (read-only) The name of the Rascal subscriber the worker consumes +* `worker.queueSubscriptionOptions` – (read-only) The Rascal subscription [subscribe options](https://github.com/guidesmiths/rascal#subscriptions) to use when subscribing * `worker.verbose` – Whether to report various state changes - +* `worker.nack` – Basic strategies that can be used for message handling + * `worker.nack.drop` – Discards or dead-letters the message + * `worker.nack.requeue` – Replaces the message back on top of the queue after a 1 second delay + * `worker.nack.republish` – Requeues the message on to the bottom of the queue after a 1 second delay + * `worker.nack.default` – Pointer to `worker.nack.republish`. + * `worker.nack._redeliveriesExceeded` – Used when a message fails redelivery attempts. Defaults to `worker.nack.default` + * `worker.nack._invalidContent` – Used when a message fails to parse. Defaults to `worker.nack.default` + +> Note: You can change `worker.nack._redeliveriesExceeded` and `worker.nack._invalidContent` to suit the needs of your application + ## Methods ### `new QueueWorker(app, options)` Creates a new instance of the worker. Use `super(app, options)` when extending. * `app` – The OkanjoApp instance to bind to * `options` – Queue worker configuration options - * `options.queueName` – (required) The name of the queue to consume - * `options.service` – (required) The QueueService instance to use for communciation - * `options.queueSubscriptionOptions` – (optional) The queue [subscribe options](https://github.com/kfitzgerald/node-amqp/tree/nack#queuesubscribeoptions-listener) to use when subscribing + * `options.subscriptionName` – (required) The name of the Rascal subscription to consume + * `options.service` – (required) The QueueService instance to use for communication + * `options.queueSubscriptionOptions` – (optional) The Rascal subscription [subscribe options](https://github.com/guidesmiths/rascal#subscriptions) to use when subscribing * `options.verbose` (optional) Whether to log various state changes. Defaults to `true`. * `options.skipInit` (optional) Whether to skip initialization/connecting at construction time. Use this for customizations or class extensions if needed. Defaults to `false`. -### `worker.handleMessage(message, callback, headers, deliveryInfo, messageObject)` +### `worker.handleMessage(message, content, ackOrNack)` Message handler. Override this function to let your application handle messages. -* `message` – The payload contained by the message -* `callback(reject, requeue)` – Function to fire when finished consuming the message. - * `reject` – Set to true to reject the message instead of acknowledging. - * `requeue` – Set to true to requeue the message if `reject` is true too. Useful if your consumer experienced a temporary error and cannot handle the message at this time, so the message goes back on top of the queue. -* `headers` – Headers included in the message -* `deliveryInfo` – Message delivery information -* `messageObject` – node-amqp message object. +* `message` – The Rascal message object +* `content` – The parsed content of the message +* `ackOrNack(err, recovery, callback)` – Acknowledge or reject the message. See [recovery strategies](https://github.com/guidesmiths/rascal#message-acknowledgement-and-recovery-strategies). -At the very least, you just need message can callback, however headers, deliveryInfo and messageObject are available if needed by your application. -See [node-amqp](https://github.com/kfitzgerald/node-amqp/tree/nack#queuesubscribeoptions-listener) for more information on headers, deliveryInfo and the messageObject parameters. ## Events @@ -318,37 +357,50 @@ Base class for batch message consumption applications. Must be extended to be us ## Properties * `worker.service` – (read-only) The QueueService instance provided when constructed -* `worker.queueName` – (read-only) The name of the queue the worker consumes -* `worker.queueSubscriptionOptions` – (read-only) The queue [subscribe options](https://github.com/kfitzgerald/node-amqp/tree/nack#queuesubscribeoptions-listener) to use when subscribing +* `worker.subscriptionName` – (read-only) The name of the Rascal subscriber the worker consumes +* `worker.queueSubscriptionOptions` – (read-only) The Rascal subscription [subscribe options](https://github.com/guidesmiths/rascal#subscriptions) to use when subscribing * `worker.verbose` – Whether to report various state changes -* `worker.batchSize` – (read-only) Up to how many messages to process at one time. +* `worker.nack` – Basic strategies that can be used for message handling + * `worker.nack.drop` – Discards or dead-letters the message + * `worker.nack.requeue` – Replaces the message back on top of the queue after a 1 second delay + * `worker.nack.republish` – Requeues the message on to the bottom of the queue after a 1 second delay + * `worker.nack.default` – Pointer to `worker.nack.republish`. + * `worker.nack._redeliveriesExceeded` – Used when a message fails redelivery attempts. Defaults to `worker.nack.default` + * `worker.nack._invalidContent` – Used when a message fails to parse. Defaults to `worker.nack.default` +* `worker.batchSize` – (read-only) Up to how many messages to process at one time. + +> Note: You can change `worker.nack._redeliveriesExceeded` and `worker.nack._invalidContent` to suit the needs of your application +> Note: Internally, the consumer prefetch count will be exactly twice the given `batchSize`. This is so the application +> can try to process the given batchSize at any given time. Async.Cargo is the primary driver for batches, so you may not +> always receive a full batch. + ## Methods ### `new BatchQueueWorker(app, options)` Creates a new instance of the worker. Use `super(app, options)` when extending. * `app` – The OkanjoApp instance to bind to * `options` – Queue worker configuration options - * `options.queueName` – (required) The name of the queue to consume - * `options.service` – (required) The QueueService instance to use for communciation - * `options.batchSize` – (optional) Up to how many messages to consume at a time. Defaults to `5`. - * `options.queueSubscriptionOptions` – (optional) The queue [subscribe options](https://github.com/kfitzgerald/node-amqp/tree/nack#queuesubscribeoptions-listener) to use when subscribing + * `options.subscriptionName` – (required) The name of the Rascal subscription to consume + * `options.service` – (required) The QueueService instance to use for communication + * `options.queueSubscriptionOptions` – (optional) The Rascal subscription [subscribe options](https://github.com/guidesmiths/rascal#subscriptions) to use when subscribing * `options.verbose` (optional) Whether to log various state changes. Defaults to `true`. - * `options.skipInit` (optional) Whether to skip initialization/connecting at construction time. Use this for customizations or class extensions if needed. Defaults to `false`. + * `options.skipInit` (optional) Whether to skip initialization/connecting at construction time. Use this for customizations or class extensions if needed. Defaults to `false`. + * `options.batchSize` – (optional) Up to how many messages to consume at a time. Defaults to `5`. -### `worker.handleMessageBatch(messages, callback)` +### `worker.handleMessageBatch(messages, defaultAckOrNack)` Batch message handler. Override this function to let your app handle messages. -* `messages` – Array of message objects (NOT PAYLOADS). Access the a message payload like so: messages[0].message. -* `callback(requeueMessages, rejectMessages)` – Function to fire when done processing the batch. - * `requeueMessages` – Optional array of message objects to requeue. You can requeue a partial amount of messages if necessary. - * `rejectMessages` – Optional array of message objects to reject and not requeue. You can reject a partial amount of messages if necessary. +* `messages` – Array of wrapped Rascal messages. + * `message[i].message` – Message object + * `message[i].content` – Parsed message content + * `message[i].ackOrNack(err, recovery, callback)` – Individual message handler. See [recovery strategies](https://github.com/guidesmiths/rascal#message-acknowledgement-and-recovery-strategies). +* `defaultAckOrNack(err, recovery, callback)` – Default message handler to apply to all messages in the batch, that have not been handled individually. See [recovery strategies](https://github.com/guidesmiths/rascal#message-acknowledgement-and-recovery-strategies). For example: -* To ack all messages, simply do `callback();` -* To requeue all messages, do `callback(messages);` -* To reject all messages, do `callback([], messages);` - -Note: **Do not manipulate `messages`**. For example, do not use array functions such as pop, push, splice, slice, etc. Doing so may result in stability issues. +* To ack an individual message: `message[i].ackOrNack();` +* To ack all messages: `defaultAckOrNack();` +* To requeue all messages: `defaultAckOrNack(true, this.nack.requeue);` +* To reject all messages, do `defaultAckOrNack(true, this.nack.drop);` ## Events @@ -368,13 +420,13 @@ Before you can run the tests, you'll need a working RabbitMQ server. We suggest For example: ```bash -docker pull rabbitmq:3.6-management -docker run -d -p 5672:5672 -p 15672:15672 -e RABBITMQ_DEFAULT_VHOST=test -e RABBITMQ_DEFAULT_USER=test -e RABBITMQ_DEFAULT_PASS=test rabbitmq:3.6-management +docker pull rabbitmq:3.7-management +docker run -d -p 5672:5672 -p 15672:15672 rabbitmq:3.7-management ``` To run unit tests and code coverage: ```sh -RABBIT_HOST=192.168.99.100 RABBIT_PORT=5672 RABBIT_USER=test RABBIT_PASS=test RABBIT_VHOST=test npm run report +RABBIT_HOST=localhost RABBIT_PORT=5672 RABBIT_USER=guest RABBIT_PASS=guest RABBIT_VHOST="/" npm run report ``` Update the `RABBIT_*` environment vars to match your docker host (e.g. host, port, user, pass, vhost, etc) diff --git a/docs/example-app/config.js b/docs/example-app/config.js index ccba783..a2cce58 100644 --- a/docs/example-app/config.js +++ b/docs/example-app/config.js @@ -2,32 +2,44 @@ // Ordinarily, you would set normally and not use environment variables, // but this is for ease of running the example across platforms -const host = process.env.RABBIT_HOST || '192.168.99.100'; +const hostname = process.env.RABBIT_HOST || 'localhost'; const port = process.env.RABBIT_PORT || 5672; -const login = process.env.RABBIT_USER || 'test'; -const password = process.env.RABBIT_PASS || 'test'; -const vhost = process.env.RABBIT_VHOST || 'test'; +const user = process.env.RABBIT_USER || 'guest'; +const password = process.env.RABBIT_PASS || 'guest'; +const vhost = process.env.RABBIT_VHOST || '/'; -module.exports = { - rabbit: { - host, - port, +const queues = { + events: "my_events", + batch: "my_batches" +}; - login, - password, +const generateConfigFromQueueNames = require('../../QueueService').generateConfigFromQueueNames; - vhost, - // What exchanges/queues to setup (they'll be configured to use the same name) - queues: { - events: "my_events", - batch: "my_batches" +module.exports = { + rabbit: { + rascal: { + vhosts: { + [vhost]: generateConfigFromQueueNames(Object.values(queues), { + connections: [ + { + hostname, + user, + password, + port, + options: { + heartbeat: 1 + }, + socketOptions: { + timeout: 1000 + } + } + ] + }) + } }, - // Handle connection drop scenarios - reconnect: true, - reconnectBackoffStrategy: 'linear', - reconnectBackoffTime: 1000, - reconnectExponentialLimit: 5000 // don't increase over 5s to reconnect + // What exchanges/queues to setup (they'll be configured to use the same name) + queues, } }; \ No newline at end of file diff --git a/docs/example-app/index.js b/docs/example-app/index.js index 0cdb45e..9c53353 100644 --- a/docs/example-app/index.js +++ b/docs/example-app/index.js @@ -21,13 +21,13 @@ if (Cluster.isMaster) { const myQueueBroker = new OkanjoBroker(app, 'my_queue_worker'); // Start the main application - app.connectToServices(() => { + app.connectToServices().then(() => { // Everything connected, now we can send out some messages to our workers // You can use service.queues.key as an enumeration when working with queues - const batchQueueName = app.services.queue.queues.batch; - const regularQueueName = app.services.queue.queues.events; + const batchQueueName = app.config.rabbit.queues.batch; + const regularQueueName = app.config.rabbit.queues.events; // Send out a batch of messages to the batch queue Async.eachSeries( diff --git a/docs/example-app/workers/MyBatchWorker.js b/docs/example-app/workers/MyBatchWorker.js index bae0c1b..e1c0081 100644 --- a/docs/example-app/workers/MyBatchWorker.js +++ b/docs/example-app/workers/MyBatchWorker.js @@ -8,24 +8,24 @@ class MyBatchWorker extends BatchQueueWorker { constructor(app) { super(app, { service: app.services.queue, - queueName: app.services.queue.queues.batch, + subscriptionName: app.config.rabbit.queues.batch, batchSize: 5 }); } - handleMessageBatch(messages, callback) { + handleMessageBatch(messages, defaultAckOrNack) { // FYI: messages will be an array of message objects, not message payloads // This worker will simply report the values of the messages it is processing - const values = messages.map((message) => message.message.my_message); + const values = messages.map((message) => message.content.my_message); console.log(`MyBatchWorker consumed messages: ${values.join(', ')}`); // ack all of the processed messages - callback([], []); + defaultAckOrNack(); // or you could reject/requeue them too: - // callback(requeueMessages, rejectMessages) + // defaultAckOrNack(err, recovery); } } diff --git a/docs/example-app/workers/MyQueueWorker.js b/docs/example-app/workers/MyQueueWorker.js index 787f970..aced1e6 100644 --- a/docs/example-app/workers/MyQueueWorker.js +++ b/docs/example-app/workers/MyQueueWorker.js @@ -1,6 +1,5 @@ "use strict"; - // const QueueWorker = require('okanjo-app-queue/QueueWorker'); const QueueWorker = require('../../../QueueWorker'); @@ -9,20 +8,20 @@ class MyQueueWorker extends QueueWorker { constructor(app) { super(app, { service: app.services.queue, - queueName: app.services.queue.queues.events, + subscriptionName: app.config.rabbit.queues.events }); } - handleMessage(message, callback, headers, deliveryInfo, messageObject) { + handleMessage(message, content, ackOrNack) { // This worker will simply report the values of the messages it is processing - console.log(`MyQueueWorker consumed message: ${message.my_message}`); + console.log(`MyQueueWorker consumed message: ${content.my_message}`); // Ack the message - callback(false, false); + ackOrNack(); // or you could reject, requeue it - // callback(reject, requeue); + // ackOrNack(err, recovery); } } diff --git a/package.json b/package.json index 72f5126..c5982b2 100644 --- a/package.json +++ b/package.json @@ -36,11 +36,8 @@ "dependencies": { "async": "^2.6.2", "okanjo-app-broker": "^1.0.0", - "amqp": "kfitzgerald/node-amqp#nack" + "rascal": "^4.2.3" }, - "bundledDependencies": [ - "amqp" - ], "nyc": { "reporter": [ "text-summary", diff --git a/test/BatchQueueWorker.test.js b/test/BatchQueueWorker.test.js new file mode 100644 index 0000000..ca557a4 --- /dev/null +++ b/test/BatchQueueWorker.test.js @@ -0,0 +1,282 @@ +"use strict"; + +const should = require('should'); + +describe('BatchQueueWorker', () => { + + const QueueService = require('../QueueService'); + const QueueWorker = require('../QueueWorker'); + const BatchQueueWorker = require('../BatchQueueWorker'); + const OkanjoApp = require('okanjo-app'); + const config = require('./config'); + + /** @type {OkanjoApp} */ + let app; + + before(async () => { + + // Create the app instance + app = new OkanjoApp(config); + + // Add the redis service to the app + app.services = { + queue: new QueueService(app, app.config.rabbit) + }; + + await app.connectToServices(); + }); + + it('should be bound to app', function () { + should(app.services.queue).be.an.Object(); + app.services.queue.should.be.instanceof(QueueService); + }); + + describe('constructor', () => { + + after(async () => { + await app.services.queue.broker.purge(); + }); + + it('throws with no options', async () => { + (() => { new BatchQueueWorker(app); }).should.throw(/options/); + }); + + it('batchSize defaults to 5', async () => { + const worker = new BatchQueueWorker(app, { + subscriptionName: 'unittests', + service: app.services.queue, + skipInit: true + }); + + worker.should.be.instanceOf(BatchQueueWorker); + worker.should.be.instanceOf(QueueWorker); + + worker.batchSize.should.be.exactly(5); + worker.queueSubscriptionOptions.prefetch.should.be.exactly(10); + }); + + it('takes custom batch size', async () => { + const worker = new BatchQueueWorker(app, { + subscriptionName: 'unittests', + service: app.services.queue, + skipInit: true, + batchSize: 50 + }); + + worker.batchSize.should.be.exactly(50); + worker.queueSubscriptionOptions.prefetch.should.be.exactly(100); + }); + + it('ignores given prefetch for batchSize', async () => { + const worker = new BatchQueueWorker(app, { + subscriptionName: 'unittests', + service: app.services.queue, + skipInit: true, + batchSize: 50, + queueSubscriptionOptions: { + prefetch: 100 + } + }); + + worker.batchSize.should.be.exactly(50); + worker.queueSubscriptionOptions.prefetch.should.be.exactly(100); + worker.queueSubscriptionOptions.retry.should.be.ok(); + }); + }); + + describe('handleMessageBatch', () => { + + afterEach(async () => { + await app.services.queue.broker.purge(); + }); + + it('should handle a batch of messages', async function () { + this.timeout(5000); + + // Publish a batch of messages + for (let i = 0; i < 10; i++) { + await app.services.queue.publishMessage("unittests", { num: i }); + } + + const worker = new BatchQueueWorker(app, { + subscriptionName: 'unittests', + service: app.services.queue, + batchSize: 5, + skipInit: true + }); + + let counter = 0; + let batch = 0; + + await new Promise(async (resolve) => { + worker.handleMessageBatch = function(messages, defaultAckOrNack) { + batch++; + counter += messages.length; + // console.log({ batch, counter, messagesInBatch: messages.length, messageNums: messages.map((m) => m.content)}); + + // wait for the cargo to fill + setTimeout(() => { + defaultAckOrNack(); + + if (counter === 10) { + setTimeout(() => { + resolve(); + }, 10); + } + }, 70); + + }.bind(worker); + + await worker.init(); + }); + + batch.should.be.greaterThanOrEqual(2); + + await new Promise((resolve) => { + setTimeout(async () => { + await worker.unsubscribe(); + resolve(); + }, 50); + }); + + }); + + it('can individually ack messages in a batch', async function () { + this.timeout(5000); + + // Publish a batch of messages + for (let i = 0; i < 10; i++) { + await app.services.queue.publishMessage("unittests", { num: i }); + } + + const worker = new BatchQueueWorker(app, { + subscriptionName: 'unittests', + service: app.services.queue, + batchSize: 5, + skipInit: true + }); + + let counter = 0; + let batch = 0; + + await new Promise(async (resolve) => { + worker.handleMessageBatch = function(messages, defaultAckOrNack) { + batch++; + counter += messages.length; + // console.log({ batch, counter, messagesInBatch: messages.length, messageNums: messages.map((m) => m.content)}); + + // Individually nack message #3, ack #8 + messages.forEach((message) => { + if (message.content.num === 3) { + message.ackOrNack(true, this.nack.drop); + } else if (message.content.num === 8) { + message.ackOrNack(); + } + }); + + // wait for the cargo to fill + setTimeout(() => { + defaultAckOrNack(); + + if (counter === 10) { + setTimeout(() => { + resolve(); + }, 10); + } + }, 70); + + }.bind(worker); + + await worker.init(); + }); + + batch.should.be.greaterThanOrEqual(2); + + await new Promise((resolve) => { + setTimeout(async () => { + await worker.unsubscribe(); + resolve(); + }, 50); + }); + + }); + + it('should handle a batch of messages as an extended class', async function () { + this.timeout(5000); + + // Publish a batch of messages + for (let i = 0; i < 10; i++) { + await app.services.queue.publishMessage("unittests", { num: i }); + } + + let worker; + let counter = 0; + let batch = 0; + + await new Promise(async (resolve) => { + + class MyBatchWorker extends BatchQueueWorker { + constructor(app) { + super(app, { + subscriptionName: 'unittests', + service: app.services.queue, + batchSize: 5 + }); + } + + handleMessageBatch(messages, defaultAckOrNack) { + batch++; + counter += messages.length; + // console.log({ batch, counter, messagesInBatch: messages.length, messageNums: messages.map((m) => m.content)}); + + // wait for the cargo to fill + setTimeout(() => { + defaultAckOrNack(); + + if (counter === 10) { + setTimeout(() => { + resolve(); + }, 10); + } + }, 70); + } + } + + // start it up! + worker = new MyBatchWorker(app); + + worker.should.be.instanceOf(BatchQueueWorker); + worker.should.be.instanceOf(QueueWorker); + }); + + batch.should.be.greaterThanOrEqual(2); + + await new Promise((resolve) => { + setTimeout(async () => { + await worker.unsubscribe(); + resolve(); + }, 50); + }); + + }); + + }); + + describe('handleMessage', () => { + + it('is not used', () => { + (() => { + const worker = new BatchQueueWorker(app, { + subscriptionName: 'unittests', + service: app.services.queue, + skipInit: true + }); + worker.handleMessage(); + }).should.throw(/does not apply/); + + }); + + }); + + +}); \ No newline at end of file diff --git a/test/QueueService.test.js b/test/QueueService.test.js new file mode 100644 index 0000000..93b4868 --- /dev/null +++ b/test/QueueService.test.js @@ -0,0 +1,246 @@ +"use strict"; + +const should = require('should'); +const TestUtil = require('./TestUtil'); + +describe('QueueService', () => { + + const QueueService = require('../QueueService'); + const OkanjoApp = require('okanjo-app'); + const config = require('./config'); + + /** @type {OkanjoApp} */ + let app; + + + // Init + before(async () => { + + // Create the app instance + app = new OkanjoApp(config); + + // Add the redis service to the app + app.services = { + queue: new QueueService(app, config.rabbit) + }; + + await app.connectToServices(); + }); + + it('should be bound to app', function () { + app.services.queue.should.be.an.Object(); + app.services.queue.should.be.instanceof(QueueService); + }); + + it('should throw config errors if not setup', () => { + const app2 = new OkanjoApp({}); + should(() => { + new QueueService(app2); + }).throw(/rascal/); + }); + + it('should throw if config is garbage', async () => { + const app = new OkanjoApp({ + rabbit: { + rascal: { + vhosts: { + "": {} + } + } + } + }); + + const service = new QueueService(app, app.config.rabbit); + service.connect().should.be.rejectedWith(/vhost/) + }); + + describe('_handleBrokerError', () => { + + it('reports whatever it gets', () => { + app.services.queue._handleBrokerError(new Error('Unit Testing')); + }); + + }); + + describe('publishMessage', () => { + + let connection; + const queue = "unittests"; + + before(async () => { + connection = await TestUtil.getConnection(); + await app.services.queue.broker.purge(); + }); + + afterEach(async () => { + await app.services.queue.broker.purge(); + }); + + it('can publish a message', async () => { + const payload = {num: 42, stuff: {things: [true]}}; + const pub = await app.services.queue.publishMessage(queue, payload); + + await new Promise((resolve) => { + pub.on('success', (messageId) => { + should(messageId).be.ok(); + resolve(); + }); + }); + + const msg = await TestUtil.getMessage(connection, queue); + JSON.parse(msg.content.toString()).should.be.deepEqual(payload); + }); + + it('can publish a message with callbacks', async () => { + const payload = {num: 42, stuff: {things: [true]}}; + + const pub = await new Promise((resolve, reject) => { + app.services.queue.publishMessage(queue, payload, (err, pub) => { + if (err) return reject(err); + resolve(pub); + }); + }); + + await new Promise((resolve) => { + pub.on('success', (messageId) => { + should(messageId).be.ok(); + resolve(); + }); + }); + + const msg = await TestUtil.getMessage(connection, queue); + JSON.parse(msg.content.toString()).should.be.deepEqual(payload); + }); + + it('fails to send a message to a bogus queue', () => { + return app.services.queue.publishMessage('bogus', {bogus: true}).should.be.rejectedWith(/bogus/); + }); + + it('fails to send a message to a bogus queue with a callback', (done) => { + app.services.queue.publishMessage('bogus', {bogus: true}, (err, pub) => { + should(err).be.ok(); + err.message.should.match(/bogus/); + should(pub).not.be.ok(); + done(); + }); + }); + + }); + + describe('generateConfigFromQueueNames', () => { + + it('can generate basic queue-name-only configs', () => { + + const queues = ["apples", "bananas", "cherries"]; + const config = QueueService.generateConfigFromQueueNames(queues); + + config.should.deepEqual({ + exchanges: ['apples', 'bananas', 'cherries'], + queues: {apples: {}, bananas: {}, cherries: {}}, + bindings: { + apples: { + source: 'apples', + destination: 'apples', + destinationType: 'queue', + bindingKey: '' + }, + bananas: { + source: 'bananas', + destination: 'bananas', + destinationType: 'queue', + bindingKey: '' + }, + cherries: { + source: 'cherries', + destination: 'cherries', + destinationType: 'queue', + bindingKey: '' + } + }, + subscriptions: { + apples: {queue: 'apples'}, + bananas: {queue: 'bananas'}, + cherries: {queue: 'cherries'} + }, + publications: { + apples: {exchange: 'apples'}, + bananas: {exchange: 'bananas'}, + cherries: {exchange: 'cherries'} + } + }); + + }); + + it('can generate basic queue-name-only configs with existing config', () => { + + const queues = ["apples", "bananas", "cherries"]; + const config = QueueService.generateConfigFromQueueNames(queues, { + connections: [ + { + hostname: "localhost", + user: "guest", + password: "guest", + port: 5672, + options: { + heartbeat: 1 + }, + socketOptions: { + timeout: 1000 + } + } + ] + }); + + config.should.deepEqual({ + connections: [ + { + hostname: "localhost", + user: "guest", + password: "guest", + port: 5672, + options: { + heartbeat: 1 + }, + socketOptions: { + timeout: 1000 + } + } + ], + exchanges: ['apples', 'bananas', 'cherries'], + queues: {apples: {}, bananas: {}, cherries: {}}, + bindings: { + apples: { + source: 'apples', + destination: 'apples', + destinationType: 'queue', + bindingKey: '' + }, + bananas: { + source: 'bananas', + destination: 'bananas', + destinationType: 'queue', + bindingKey: '' + }, + cherries: { + source: 'cherries', + destination: 'cherries', + destinationType: 'queue', + bindingKey: '' + } + }, + subscriptions: { + apples: {queue: 'apples'}, + bananas: {queue: 'bananas'}, + cherries: {queue: 'cherries'} + }, + publications: { + apples: {exchange: 'apples'}, + bananas: {exchange: 'bananas'}, + cherries: {exchange: 'cherries'} + } + }); + + }); + + }); +}); \ No newline at end of file diff --git a/test/QueueWorker.test.js b/test/QueueWorker.test.js new file mode 100644 index 0000000..724e061 --- /dev/null +++ b/test/QueueWorker.test.js @@ -0,0 +1,476 @@ +"use strict"; + +const should = require('should'); + +// process.env.DEBUG='rascal:Subscription,rascal:SubscriberError,rascal:SubscriberSession'; + +describe('QueueWorker', () => { + + const QueueService = require('../QueueService'); + const QueueWorker = require('../QueueWorker'); + const OkanjoApp = require('okanjo-app'); + const config = require('./config'); + + /** @type {OkanjoApp} */ + let app; + + before(async () => { + + // Create the app instance + app = new OkanjoApp(config); + + // Add the redis service to the app + app.services = { + queue: new QueueService(app, app.config.rabbit) + }; + + await app.connectToServices(); + }); + + it('should be bound to app', function () { + should(app.services.queue).be.an.Object(); + app.services.queue.should.be.instanceof(QueueService); + }); + + describe('constructor', () => { + + after(async () => { + await app.services.queue.broker.purge(); + }); + + it('throws when subscriptionName is missing', () => { + (() => { new QueueWorker(app, {}); }).should.throw(/subscriptionName/); + }); + + it('throws when service is missing', () => { + (() => { new QueueWorker(app, {subscriptionName: 'unittests'}); }).should.throw(/service/); + }); + + it('can construct', async () => { + const worker = new QueueWorker(app, { + subscriptionName: 'unittests', + service: app.services.queue + }); + + should(worker).be.ok(); + + await new Promise((resolve) => { + setTimeout(async () => { + await worker.unsubscribe(); + resolve(); + }, 50); + }); + }); + + it('can construct with subscriber options', async () => { + const worker = new QueueWorker(app, { + subscriptionName: 'unittests', + service: app.services.queue, + queueSubscriptionOptions: { + prefetch: 2, + retry: { delay: 1000 } + } + }); + + should(worker).be.ok(); + worker.queueSubscriptionOptions.prefetch.should.be.exactly(2); + + await new Promise((resolve) => { + setTimeout(async () => { + await worker.unsubscribe(); + resolve(); + }, 50); + }); + }); + + it('can construct without verbosity', async () => { + const worker = new QueueWorker(app, { + subscriptionName: 'unittests', + service: app.services.queue, + verbose: false + }); + + should(worker).be.ok(); + worker.verbose.should.be.exactly(false); + + worker.log('stealth as the night'); + + await new Promise((resolve) => { + setTimeout(async () => { + await worker.unsubscribe(); + resolve(); + }, 50); + }); + }); + + it('can construct without starting', async () => { + const worker = new QueueWorker(app, { + subscriptionName: 'unittests', + service: app.services.queue, + skipInit: true + }); + + should(worker).be.ok(); + + await new Promise((resolve) => { + setTimeout(async () => { + should(worker.subscription).not.be.ok(); + resolve(); + }, 50); + }); + + }); + + }); + + describe('subscribe', () => { + + afterEach(async () => { + await app.services.queue.broker.purge(); + }); + + it('refuses to subscribe a second time', async () => { + const worker = new QueueWorker(app, { + subscriptionName: 'unittests', + service: app.services.queue, + }); + + should(worker).be.ok(); + + await new Promise((resolve) => { + setTimeout(async () => { + resolve(); + }, 50); + }); + + try { + await worker.subscribe(); + should(false).exactly(true); + } catch(err) { + err.message.should.match(/Already subscribed/); + } + + await new Promise((resolve) => { + setTimeout(async () => { + await worker.unsubscribe(); + resolve(); + }, 50); + }); + }); + + it('throws when subscribing to a bogus queue', async () => { + const worker = new QueueWorker(app, { + subscriptionName: 'bogus', + service: app.services.queue, + skipInit: true + }); + + should(worker).be.ok(); + + try { + await worker.subscribe(); + should(false).should.be.exactly(true); + } catch (err) { + err.should.match(/bogus/) + } + }); + + }); + + describe('onRedeliveriesExceeded', () => { + + before(async () => { + await app.services.queue.broker.purge(); + }); + + afterEach(async () => { + await app.services.queue.broker.purge(); + }); + + it('should exceed deliveries', async function() { + this.timeout(5000); + let messageId; + + // Fire the message, let it sit in the queue + const pub = await app.services.queue.publishMessage("unittests", { onRedeliveriesExceeded: 1 }); + pub.on('success', (id) => { + messageId = id; + }); + + const worker = new QueueWorker(app, { + subscriptionName: 'unittests', + service: app.services.queue, + skipInit: true + }); + + should(worker).be.ok(); + + // change default redelivery from republish to drop + worker.nack._redeliveriesExceeded = worker.nack.drop; + + // Wait a sec for the connection to go through + await new Promise(async (resolve) => { + worker.onSubscribed = function() { + resolve(); + }; + await worker.subscribe(); + }); + + let counter = 0; + const max = app.config.rabbit.rascal.vhosts['/'].subscriptions["unittests"].redeliveries.limit+1; + + // Wait for the message to hit 11 times (1 real + 10 retries) + await new Promise(async (resolve) => { + + // Ensure the message is valid and count the retries + worker.handleMessage = function(message, content, ackOrNack) { + // nack + requeue + counter++; + counter.should.be.lessThanOrEqual(max); + messageId.should.be.exactly(message.properties.messageId); + // console.log(counter, message.properties.rascal); + ackOrNack(true, { strategy: 'nack', requeue: true, defer: 10 }); + + if (counter === max) { + resolve(); + } + }.bind(worker); + + }); + + // Disconnect + await new Promise((resolve) => { + setTimeout(async () => { + await worker.unsubscribe(); + resolve(); + }, 50); + }); + + }); + + }); + + describe('onInvalidContent', () => { + + before(async () => { + await app.services.queue.broker.purge(); + }); + + afterEach(async () => { + await app.services.queue.broker.purge(); + }); + + it('should toss messages with bad content', async function() { + this.timeout(5000); + + const worker = new QueueWorker(app, { + subscriptionName: 'unittests', + service: app.services.queue, + }); + + should(worker).be.ok(); + + // change default redelivery from republish to drop + worker.nack._invalidContent = worker.nack.drop; + + // Wait a sec for the connection to go through + await new Promise((resolve) => { + setTimeout(async () => { + resolve(); + }, 50); + }); + + // Wait for the message to hit 11 times (1 real + 10 retries) + await new Promise(async (resolve) => { + + // Ensure the message is valid and count the retries + worker.handleMessage = function(/*message, content, ackOrNack*/) { + throw('Should not have gotten here'); + }.bind(worker); + + // Fire the message + await app.services.queue.publishMessage("unittests", "{invalid:content}", { options: { contentType: "application/json" }}); + + setTimeout(() => { + resolve(); + }, 50); + }); + + // Disconnect + await new Promise((resolve) => { + setTimeout(async () => { + await worker.unsubscribe(); + resolve(); + }, 50); + }); + + }); + + }); + + describe('onSubscriptionError', () => { + + before(async () => { + await app.services.queue.broker.purge(); + }); + + afterEach(async () => { + await app.services.queue.broker.purge(); + }); + + it('should report subscription errors', async function() { + this.timeout(5000); + + const worker = new QueueWorker(app, { + subscriptionName: 'unittests', + service: app.services.queue, + }); + + should(worker).be.ok(); + + // Wait a sec for the connection to go through + await new Promise((resolve) => { + setTimeout(async () => { + resolve(); + }, 50); + }); + + let counter = 0; + + // Wait for the message to hit 11 times (1 real + 10 retries) + await new Promise(async (resolve, reject) => { + + // Ensure the message is valid and count the retries + worker.handleMessage = function(message, content, ackOrNack) { + counter++; + + if (counter === 1) { + const err = new Error('boop'); + ackOrNack(err, {strategy: 'unknown'}); + + setTimeout(async () => { + await worker.unsubscribe(); + await worker.subscribe(); + }, 50); + + } else if (counter === 2) { + ackOrNack(); + setTimeout(() => resolve(), 50); + } else { + reject('should not have gotten here'); + } + + }.bind(worker); + + // Fire the message + await app.services.queue.publishMessage("unittests", "explode", { options: { expiration: 100 }}); + }); + + // Disconnect + await new Promise((resolve) => { + setTimeout(async () => { + await worker.unsubscribe(); + resolve(); + }, 50); + }); + + }); + + }); + + describe('unsubscribe', () => { + + before(async () => { + await app.services.queue.broker.purge(); + }); + + after(async () => { + await app.services.queue.broker.purge(); + }); + + it('should ignore a double unsubscribe', async () => { + const worker = new QueueWorker(app, { + subscriptionName: 'unittests', + service: app.services.queue + }); + + should(worker).be.ok(); + + await new Promise((resolve) => { + setTimeout(async () => { + await worker.unsubscribe(); + resolve(); + }, 50); + }); + + await new Promise((resolve) => { + setTimeout(async () => { + await worker.unsubscribe(); + resolve(); + }, 50); + }); + }); + + }); + + describe('prepareForShutdown', () => { + + before(async () => { + await app.services.queue.broker.purge(); + }); + + after(async () => { + await app.services.queue.broker.purge(); + }); + + it('should prepareForShutdown', async () => { + + const worker = new QueueWorker(app, { + subscriptionName: 'unittests', + service: app.services.queue + }); + + await new Promise((resolve) => { + setTimeout(async () => { + worker.prepareForShutdown(); + resolve(); + }, 100); + }); + + }); + + it('should prepareForShutdown a second time for fun', async () => { + + const handler = function(err) { + console.log('ATE', err); // eslint-disable-line no-console + }; + + process.once('uncaughtException', handler); + + + const worker = new QueueWorker(app, { + subscriptionName: 'unittests', + service: app.services.queue + }); + + await new Promise((resolve) => { + setTimeout(async () => { + worker.prepareForShutdown(); + resolve(); + }, 100); + }); + + await new Promise((resolve) => { + setTimeout(async () => { + worker.prepareForShutdown(); + resolve(); + }, 100); + }); + + process.off('uncaughtException', handler); + + }); + + }); + +}); \ No newline at end of file diff --git a/test/TestUtil.js b/test/TestUtil.js new file mode 100644 index 0000000..a599205 --- /dev/null +++ b/test/TestUtil.js @@ -0,0 +1,24 @@ +"use strict"; + +const amqplib = require('amqplib/callback_api'); + +exports.getMessage = function getMessage(connection, queue) { + return new Promise((resolve, reject) => { + connection.createChannel((err, channel) => { + if (err) return reject(err); + channel.get(queue, { noAck: true }, (err, message) => { + if (err) return reject(err); + return resolve(message); + }); + }); + }); +}; + +exports.getConnection = function getConnection() { + return new Promise((resolve, reject) => { + amqplib.connect(function(err, connection) { + if (err) return reject(err); + resolve(connection); + }); + }); +}; \ No newline at end of file diff --git a/test/batch_queue_worker_test.js b/test/batch_queue_worker_test.js deleted file mode 100644 index 0ab7971..0000000 --- a/test/batch_queue_worker_test.js +++ /dev/null @@ -1,234 +0,0 @@ -"use strict"; - -const should = require('should'); -const Async = require('async'); - -describe('BatchQueueWorker', () => { - - "use strict"; - - const BatchQueueWorker = require('../BatchQueueWorker'); - const QueueService = require('../QueueService'); - const OkanjoApp = require('okanjo-app'); - const config = require('./config'); - - const queueName = 'unittest_batch'; - - let worker; - let currentMessageHandler = null; - - let app, go = false; - - class UnitTestQueueWorker extends BatchQueueWorker { - - constructor(app, queueName) { - super(app, { - queueName: queueName - //, batchSize: 5 // default size is 5 - }); - } - - handleMessageBatch(messages, callback) { - if (currentMessageHandler) currentMessageHandler(messages, callback); - else callback(messages); // requeue - } - } - - it('can be extended and initialized', function(done) { - - app = new OkanjoApp(config); - app.services = { - queue: new QueueService(app, app.config.rabbit, { unittest_batch: queueName }) - }; - - - app.connectToServices(() => { - app.services.queue.activeQueues[queueName].purge().addCallback((/*res*/) => { - //console.log('CLEANUP: ', res); - - worker = new UnitTestQueueWorker(app, queueName); - should(worker).be.ok(); - - done(); - }); - }); - }); - - it('can receive a message', function(done) { - - let sent = false; - // const batches = 0; - let rejectedNumber7 = false, - rereceivedNumber7 = false, - droppedNumber8 = false, - received = 0; - - function checkDone() { - if (sent && received >= 10 && rereceivedNumber7) { - currentMessageHandler = null; - done(); - } - } - - // Define the handler for this test - currentMessageHandler = function(messages, doneWithBatch) { - - // don't process the message until go() is called - if (go === false) { - go = () => { - currentMessageHandler(messages, doneWithBatch); - }; - return; - } - - // Expected: first batch: 1 message (the one that game in) - // Next batch: 5 messages - // Last batch: 4 messages - - //console.log(`GOT BATCH: ${++batches}`, messages.map((m) => { return {m:m.message, tag: m.messageObject.deliveryTag}}), messages.length); - - received += messages.length; - - messages.forEach((message) => { - message.message.test.should.match(/Batch message/); - }); - - const lucky7 = messages.find((m) => m.message.number === 7); // reject #7 and accept it on the second try - const lucky8 = messages.find((m) => m.message.number === 8); // reject and drop #8, should never see it again - - const requeue = []; - const drop = []; - - if (lucky7) { - if (rejectedNumber7) { - // we got it again! - //console.log('GOT IT A AGAIN!'); - rereceivedNumber7 = true; - } else { - //console.log('REJECTING'); - rejectedNumber7 = true; - requeue.push(lucky7); - } - } - - if (lucky8) { - should(droppedNumber8).be.exactly(false); // should not have received this a second time - droppedNumber8 = true; - drop.push(lucky8); - } - - doneWithBatch(requeue, drop); - - // See if we're done yet - checkDone(); - - //setTimeout(function() { - // message.should.be.an.Object(); - // doneWithTheMessage.should.be.a.Function(); - // headers.should.be.an.Object(); - // deliveryInfo.should.be.an.Object(); - // messageObject.should.be.an.Object(); - // - // message.test.should.be.equal('UnitTestQueueWorker can receive a message'); - // - // should(received).be.exactly(false); - // should(sent).be.exactly(true); - // received = true; - // - // - // // consume the message - // doneWithTheMessage(false, false); - // - // checkDone(); - //}, 10); - }; - - // Push 10 messages in the queue - Async.times(10, (i, next) => { - app.services.queue.publishMessage(queueName, { test: 'Batch message', number: i }, (err) => { - should(err).not.be.ok(); - - sent = true; - - next(); - }); - }, () => { - // Now that we pushed them all, let the worker roll - go(); - }); - }); - - it('can shutdown gracefully', function(done) { - this.timeout(10000); - - let sent = false; - // const lateSent = false; - let received = false; - - - // Intercept the shutdown - worker.shutdown = function() { - - sent.should.be.exactly(true); - received.should.be.exactly(true); - //lateSent.should.be.exactly(true); - worker._isSubscribed.should.be.exactly(false); - worker._isShuttingDown.should.be.exactly(true); - - currentMessageHandler = null; - - //// Cleanup that left over message - //worker.queue.purge().addCallback(function(res) { - // res.messageCount.should.be.exactly(1); - done(); - //}); - }; - - currentMessageHandler = function(messages, doneWithTheBatch) { - setTimeout(function() { - messages.should.be.ok(); - doneWithTheBatch.should.be.a.Function(); - - sent.should.be.exactly(true); - received.should.be.exactly(false); - - messages[0].message.test.should.be.equal('UnitTestQueueWorker can shutdown'); - - received = true; - - // simulate a process shutdown - worker._isShuttingDown.should.be.exactly(false); - worker.prepareForShutdown(true); - worker._isShuttingDown.should.be.exactly(true); - - // Publish another message to the queue while shutdown started - - // it should NOT be handled and remain in the queue - //app.services.queue.publishMessage(queueName, { test: 'UnitTestQueueWorker message after shutdown' }, function(err) { - // app.inspect(err); - // should(err).not.be.ok(); - // lateSent = true; - //}); - - // with this delay, the prepare shutdown should fire a retry at least once before we finished processing the message - setTimeout(function() { - doneWithTheBatch(); - worker._cargo.length().should.be.exactly(0); - }, 25); - }, 10); - }; - - // We should be subscribed - worker._isSubscribed.should.be.exactly(true); - - // push a message into the queue and wait to consume it - app.services.queue.publishMessage(queueName, { test: 'UnitTestQueueWorker can shutdown' }, function(err) { - should(err).not.be.ok(); - should(received).be.exactly(false); - - sent = true; - }); - - }); - - -}); \ No newline at end of file diff --git a/test/config.js b/test/config.js index 13d9cd4..d2a52dc 100644 --- a/test/config.js +++ b/test/config.js @@ -1,25 +1,72 @@ // For unit testing, pull env config from env vars -const host = process.env.RABBIT_HOST || 'localhost'; +const hostname = process.env.RABBIT_HOST || 'localhost'; const port = process.env.RABBIT_PORT || 5672; -const login = process.env.RABBIT_USER || 'test'; -const password = process.env.RABBIT_PASS || 'test'; -const vhost = process.env.RABBIT_VHOST || 'test'; +const user = process.env.RABBIT_USER || 'guest'; +const password = process.env.RABBIT_PASS || 'guest'; +const vhost = process.env.RABBIT_VHOST || '/'; module.exports = { rabbit: { - host, - port, - - login, - password, - - vhost, - - // Handle connection drop scenarios - reconnect: true, - reconnectBackoffStrategy: 'linear', - reconnectBackoffTime: 1000, - reconnectExponentialLimit: 5000 // don't increase over 5s to reconnect + rascal: { + vhosts: { + [vhost]: { + connections: [ + { + hostname, + user, + password, + port, + options: { + heartbeat: 1 + }, + socketOptions: { + timeout: 1000 + } + } + ], + exchanges: [ + "unittests" + ], + queues: { + "unittests": {} + }, + bindings: { + // "unittests -> unittests": {} + "unittests": { + source: "unittests", + destination: "unittests", + destinationType: "queue", + bindingKey: "" // typically defaults to #, does this matter? + } + }, + subscriptions: { + "unittests": { + queue: "unittests", + redeliveries: { + limit: 10, + counter: "shared" + }, + deferCloseChannel: 5, + } + }, + publications: { + "unittests": { + exchange: "unittests", + // routingKey: "something" + } + } + } + }, + // Define counter(s) for counting redeliveries + redeliveries: { + counters: { + shared: { + size: 10, + type: "inMemory" + } + } + } + } } }; \ No newline at end of file diff --git a/test/queue_test.js b/test/queue_test.js deleted file mode 100644 index 3fe5844..0000000 --- a/test/queue_test.js +++ /dev/null @@ -1,674 +0,0 @@ -"use strict"; - -const should = require('should'); - -//process.env.NODE_DEBUG_AMQP = 1; - -const disableReportingByDefault = !!process.env.SILENCE_REPORTS; - -function toggleReporting(state) { - process.env.SILENCE_REPORTS = !(state && !disableReportingByDefault); -} - - -describe('QueueService', () => { - - const QueueService = require('../QueueService'); - const OkanjoApp = require('okanjo-app'); - const config = require('./config'); - - /** - * App - * @type {OkanjoApp} - */ - let app; - - - // Init - before(function(done) { - - // Create the app instance - app = new OkanjoApp(config); - - // Add the redis service to the app - app.services = { - queue: new QueueService(app), - queueAuto: new QueueService(app, null, { unitTestAuto: 'unittests_auto' }) // <-- automatic binding of exchanges - }; - - app.connectToServices(done); - }); - - it('should be bound to app', function () { - app.services.queue.should.be.an.Object(); - app.services.queue.should.be.instanceof(QueueService); - }); - - it('should throw config errors if not setup', () => { - const app2 = new OkanjoApp({}); - should(() => { - new QueueService(app2); - }).throw(/configuration/); - }); - - it('can bind arbitrary queue, publish, and consume', function(done) { - - const queueName = 'unittests', - originalMessage = { - id: Math.round(Math.random() * 10000), - s: "hello", - d: new Date() - }; - - // Bind the unit test exchange/queue - // noinspection JSAccessibilityCheck - app.services.queue._bindQueueExchange(queueName, function() { - - // Pull the rabbit queue so qe can consume it - const queue = app.services.queue.activeQueues[queueName], - state = { - subscribed: false, - tag: null, - messageReceived: false, - messageRejected: false, - messageReceivedAgain: false - }; - should(queue).be.ok(); - - queue.purge().addCallback(function(res) { - - if (res.messageCount) - console.log(`Purged ${res.messageCount} messages from the ${queueName} queue`); /* eslint-disable-line no-console */ - - // Create a consumer - queue.subscribe({ ack: true, prefetchCount: 1 }, function(message) { - - state.subscribed.should.be.exactly(true); - - // Message received! - // Check the message - message.should.be.an.Object(); - message.id.should.be.equal(originalMessage.id); - message.s.should.be.equal(originalMessage.s); - message.d.should.be.equal(originalMessage.d.toJSON()); - - // First, we should receive the message, but we're going to reject it - // so we can receive it again - if (!state.messageReceived) { - state.messageReceived = true; - - // Reject the message - state.messageRejected.should.be.exactly(false); - state.messageRejected = true; - queue.shift(true, true); // reject, requeue - - } else if (!state.messageReceivedAgain) { - state.messageReceivedAgain = true; - - // Confirm the message - state.messageRejected.should.be.exactly(true); - queue.shift(false, false); // no reject, no requeue - - // Cleanup! - queue.unsubscribe(state.tag).addCallback(function(res) { - res.should.be.an.Object(); - res.consumerTag.should.be.ok(); - - done(); - }); - - } else { - throw new Error('Invalid queue state! No idea what\'s going on'); - } - - }).addCallback(function(res) { - // The consumer has subscribed - state.subscribed.should.be.exactly(false); - state.subscribed = true; - - should(state.tag).not.be.ok(); - should(res).be.ok(); - - res.consumerTag.should.be.ok(); - state.tag = res.consumerTag; - - // Publish a message - app.services.queue.publishMessage(queueName, originalMessage, function(err) { - should(err).not.be.ok(); - }); - }); - }); - }); - }); - - it('can publish and consume a message with options', function(done) { - - const queueName = 'unittests', - originalMessage = { - id: Math.round(Math.random() * 10000), - s: "hello", - d: new Date() - }; - - // Bind the unit test exchange/queue - // noinspection JSAccessibilityCheck - app.services.queue._bindQueueExchange(queueName, function() { - - // Pull the rabbit queue so qe can consume it - const queue = app.services.queue.activeQueues[queueName], - state = { - subscribed: false, - tag: null, - messageReceived: false, - messageRejected: false, - messageReceivedAgain: false - }; - should(queue).be.ok(); - - // Create a consumer - queue.subscribe({ ack: true, prefetchCount: 1 }, function(message, headers, deliveryInfo, messageObject) { - - //console.log('received!', arguments); - - // - state.subscribed.should.be.exactly(true); - headers.should.be.an.Object(); - headers['x-okanjo-was-here'].should.be.equal('yes'); - - // Check that the headers are in the raw info - deliveryInfo.should.be.an.Object(); - deliveryInfo.headers['x-okanjo-was-here'].should.be.equal('yes'); - - // The raw message - messageObject.should.be.an.Object(); - - - // Message received! - // Check the message - message.should.be.an.Object(); - message.id.should.be.equal(originalMessage.id); - message.s.should.be.equal(originalMessage.s); - message.d.should.be.equal(originalMessage.d.toJSON()); - - // First, we should receive the message, but we're going to reject it - // so we can receive it again - if (!state.messageReceived) { - state.messageReceived = true; - - // Rabbit should know that this is the first appearance of this message to the app - deliveryInfo.redelivered.should.be.exactly(false); - - // Reject the message - state.messageRejected.should.be.exactly(false); - state.messageRejected = true; - queue.shift(true, true); // reject, requeue - - } else if (!state.messageReceivedAgain) { - state.messageReceivedAgain = true; - - // Rabbit should know that this message was rejected before - deliveryInfo.redelivered.should.be.exactly(true); - - // Confirm the message - state.messageRejected.should.be.exactly(true); - queue.shift(false, false); // no reject, no requeue - - // Cleanup! - queue.unsubscribe(state.tag).addCallback(function(res) { - res.should.be.an.Object(); - res.consumerTag.should.be.ok(); - - done(); - }); - - } else { - throw new Error('Invalid queue state! No idea what\'s going on'); - } - - }).addCallback(function(res) { - // The consumer has subscribed - state.subscribed.should.be.exactly(false); - state.subscribed = true; - - should(state.tag).not.be.ok(); - should(res).be.ok(); - - res.consumerTag.should.be.ok(); - state.tag = res.consumerTag; - - // Publish a message - app.services.queue.publishMessage(queueName, originalMessage, { headers: { "x-okanjo-was-here": 'yes' } }, function(err) { - // If res is true, then there was an error (terrible convention) - should(err).not.be.ok(); - }); - }); - }); - }); - - describe('Queue Worker', function() { - "use strict"; - - const queueName = 'unittests'; - - let worker; - - const QueueWorker = require('../QueueWorker'); - //const UnitTestQueueWorker = require('./unittest_queue_worker'); - const OkanjoWorker = require('okanjo-app-broker').OkanjoWorker; - - let currentMessageHandler = null; - - class UnitTestQueueWorker extends QueueWorker { - - constructor(app, queueName) { - super(app, { - queueName: queueName - }); - } - - handleMessage(message, callback, /* you might not care about the rest of these params */ headers, deliveryInfo, messageObject) { - if (currentMessageHandler) currentMessageHandler(message, callback, headers, deliveryInfo, messageObject); - } - } - - - it('cannot be instantiated without a queueName', function() { - (function() { - new QueueWorker(app, {}) - }).should.throw('Missing require option: queueName'); - }); - - - it('can be extended and initialized', function() { - - // Create the instance and start it - worker = new UnitTestQueueWorker(app, queueName); - - worker.should.be.instanceof(UnitTestQueueWorker); - worker.should.be.instanceof(QueueWorker); - worker.should.be.instanceof(OkanjoWorker); - - }); - - it('can receive a message', function(done) { - - let sent = false, - received = false; - - function checkDone() { - if (sent && received) { - currentMessageHandler = null; - done(); - } - } - - // Define the handler for this test - currentMessageHandler = function(message, doneWithTheMessage, headers, deliveryInfo, messageObject) { - setTimeout(function() { - message.should.be.an.Object(); - doneWithTheMessage.should.be.a.Function(); - headers.should.be.an.Object(); - deliveryInfo.should.be.an.Object(); - messageObject.should.be.an.Object(); - - message.test.should.be.equal('UnitTestQueueWorker can receive a message'); - - should(received).be.exactly(false); - should(sent).be.exactly(true); - received = true; - - - // consume the message - doneWithTheMessage(false, false); - - checkDone(); - }, 10); - }; - - // push a message into the queue and wait to consume it - app.services.queue.publishMessage(queueName, { test: 'UnitTestQueueWorker can receive a message' }, function(err) { - should(err).not.be.ok(); - should(received).be.exactly(false); - - sent = true; - checkDone(); - }); - - }); - - - - it('can reject and retry a message', function(done) { - this.timeout(5000); - - let sent = false, - received = false, - rejected = false, - receivedAgain = false; - - function checkDone() { - if (sent && received && rejected && receivedAgain) { - currentMessageHandler = null; - done(); - } - } - - // Define the handler for this test - currentMessageHandler = function(message, doneWithTheMessage, headers, deliveryInfo, messageObject) { - // console.log('RECEIVED') - setTimeout(() => { - // console.log('RECEIVE PROCESSING') - message.should.be.an.Object(); - doneWithTheMessage.should.be.a.Function(); - headers.should.be.an.Object(); - deliveryInfo.should.be.an.Object(); - messageObject.should.be.an.Object(); - - message.test.should.be.equal('UnitTestQueueWorker can receive and reject a message'); - - should(sent).be.exactly(true); - - if (!received) { - rejected.should.be.exactly(false); - receivedAgain.should.be.exactly(false); - received = true; - - // Reject it so we get it again - rejected = true; - - // consume the message - doneWithTheMessage(true, true); - } else { - // We rejected it already, so accept it - receivedAgain.should.be.exactly(false); - receivedAgain = true; - - doneWithTheMessage(false, false); - - checkDone(); - } - }, 50); // setImmediate too fast for rabbit-3.6, ok for rabbit-3.5 - }; - - // push a message into the queue and wait to consume it - // console.log('SENDING') - app.services.queue.publishMessage(queueName, { test: 'UnitTestQueueWorker can receive and reject a message' }, function(err) { - // console.log('SENT') - should(err).not.be.ok(); - should(received).be.exactly(false); - - sent = true; - checkDone(); - }); - - }); - - - it('should recover from an error gracefully', function(done) { - this.timeout(5000); - - toggleReporting(false); - - let errorEmitted = false, - sent = false, - //resubscribed = false, - received = false; - - function checkDone() { - if (errorEmitted && sent /*&& resubscribed*/ && received) { - currentMessageHandler = null; - toggleReporting(true); - done(); - } - } - - // Setup a message handler for this test - currentMessageHandler = function(message, doneWithTheMessage, headers, deliveryInfo, messageObject) { - setTimeout(function() { - //console.log('GOT MESSAGE FROM', deliveryInfo) - message.should.be.an.Object(); - doneWithTheMessage.should.be.a.Function(); - headers.should.be.an.Object(); - deliveryInfo.should.be.an.Object(); - messageObject.should.be.an.Object(); - - sent.should.be.exactly(true); - received.should.be.exactly(false); - errorEmitted.should.be.exactly(true); - //resubscribed.should.be.exactly(true); // <-- if this hit, its because the message was consumed even though we unsub'd - - message.test.should.be.equal('UnitTestQueueWorker can recover'); - - received = true; - - worker._isProcessing.should.be.exactly(true); - doneWithTheMessage(false, false); - worker._isProcessing.should.be.exactly(false); - - // we should be subscribed again - worker._isSubscribed.should.be.exactly(true); - - checkDone(); - }, 10); - }; - - - // We should be subscribed - worker._isSubscribed.should.be.exactly(true); - - // Unsubscribe - errorEmitted = true; - worker.service.rabbit.emit('error', { code: 'ETIMEDOUT', errno: 'ETIMEDOUT', syscall: 'read', faked: true }); - - worker.service.rabbit.once('ready', () => { - - // Wait a sec for it to recover - setTimeout(() => { - - // Push a message in the queue - // push a message into the queue and wait to consume it - app.services.queue.publishMessage(queueName, { test: 'UnitTestQueueWorker can recover' }, function(err) { - should(err).not.be.ok(); - - sent.should.be.exactly(false); - received.should.be.exactly(false); - - sent = true; - }); - - }, 250); - }); - }); - - - it('should unsubscribe and resubscribe gracefully', function(done) { - this.timeout(12000); - - let unsubscribed = false, - sent = false, - resubscribed = false, - received = false; - - function checkDone() { - if (unsubscribed && sent && resubscribed && received) { - currentMessageHandler = null; - done(); - } - } - - // Setup a message handler for this test - currentMessageHandler = function(message, doneWithTheMessage, headers, deliveryInfo, messageObject) { - // console.log('RECEIVED', headers, deliveryInfo) - setTimeout(function() { - // console.log('RECEIVE PROCESSING') - message.should.be.an.Object(); - doneWithTheMessage.should.be.a.Function(); - headers.should.be.an.Object(); - deliveryInfo.should.be.an.Object(); - messageObject.should.be.an.Object(); - - sent.should.be.exactly(true); - received.should.be.exactly(false); - unsubscribed.should.be.exactly(true); - message.test.should.be.equal('UnitTestQueueWorker can resubscribe'); - resubscribed.should.be.exactly(true); // <-- if this hit, its because the message was consumed even though we unsub'd - - - received = true; - - worker._isProcessing.should.be.exactly(true); - doneWithTheMessage(false, false); - worker._isProcessing.should.be.exactly(false); - - checkDone(); - }, 1000); - }; - - - // We should be subscribed - worker._isSubscribed.should.be.exactly(true); - - //console.log('STILL SUBd') - - // Unsubscribe - // console.log('UNSUB') - worker.unsubscribe(function() { - // console.log('UNSUB DONE') - unsubscribed = true; - worker._isSubscribed.should.be.exactly(false); - - //console.log('UNSUBd') - - // Calling unsubscribe again should do nothing - // console.log('UNSUB AGAIN') - worker.unsubscribe((/*err*/) => { - // console.log('UNSUB AGAIN DONE') - worker._isSubscribed.should.be.exactly(false); - - resubscribed.should.be.exactly(false); - - //console.log('STILL UNSUBd') - - setTimeout(() => { - - // Push a message in the queue - // push a message into the queue and wait to consume it - // console.log('SENDING...') - app.services.queue.publishMessage(queueName, { test: 'UnitTestQueueWorker can resubscribe' }, function(err) { - // console.log('SENT!') - should(err).not.be.ok(); - - //console.log('sent...') - - sent.should.be.exactly(false); - received.should.be.exactly(false); - - sent = true; - - // Delay for a bit, to make sure there were no consumers - setTimeout(function() { - - // - no consumers, hopefully - received.should.be.exactly(false); - - // Do we need a `resubscribing` state check to prevent race conditions? - - // Subscribe - // console.log('RESUBSCRIBING...') - worker.subscribe(function() { - // console.log('RESUBSCRIBED!') - resubscribed = true; - worker._isSubscribed.should.be.exactly(true); - - // Wait for the handler to finish up - // - consume the message - // Done - - }); - - }, 250); - }); - }, 1000) - - }); - }); - }); - - it('can shutdown gracefully', function(done) { - this.timeout(10000); - - let sent = false, - lateSent = false, - received = false; - - - // Inctercept the - worker.shutdown = function() { - - sent.should.be.exactly(true); - received.should.be.exactly(true); - lateSent.should.be.exactly(true); - worker._isSubscribed.should.be.exactly(false); - worker._isShuttingDown.should.be.exactly(true); - - currentMessageHandler = null; - - // Cleanup that left over message if present - worker.queue.purge().addCallback(function(/*res*/) { - // res.messageCount.should.be.exactly(1); - done(); - }); - }; - - currentMessageHandler = function(message, doneWithTheMessage, headers, deliveryInfo, messageObject) { - setTimeout(function() { - message.should.be.an.Object(); - doneWithTheMessage.should.be.a.Function(); - headers.should.be.an.Object(); - deliveryInfo.should.be.an.Object(); - messageObject.should.be.an.Object(); - - sent.should.be.exactly(true); - received.should.be.exactly(false); - - message.test.should.be.equal('UnitTestQueueWorker can shutdown'); - - received = true; - - // simulate a process shutdown - worker._isShuttingDown.should.be.exactly(false); - worker.prepareForShutdown(true); - worker._isShuttingDown.should.be.exactly(true); - - // Publish another message to the queue while shutdown started - - // it should NOT be handled and remain in the queue - app.services.queue.publishMessage(queueName, { test: 'UnitTestQueueWorker message after shutdown' }, function(err) { - should(err).not.be.ok(); - lateSent = true; - }); - - // with this delay, the prepare shutdown should fire a retry at least once before we finished processing the message - setTimeout(function() { - worker._isProcessing.should.be.exactly(true); - doneWithTheMessage(false, false); - worker._isProcessing.should.be.exactly(false); - }, 25); - }, 10); - }; - - // We should be subscribed - worker._isSubscribed.should.be.exactly(true); - - // push a message into the queue and wait to consume it - app.services.queue.publishMessage(queueName, { test: 'UnitTestQueueWorker can shutdown' }, function(err) { - should(err).not.be.ok(); - should(received).be.exactly(false); - - sent = true; - }); - - }); - - }); - -}); \ No newline at end of file diff --git a/yarn.lock b/yarn.lock deleted file mode 100644 index a5c8cd0..0000000 --- a/yarn.lock +++ /dev/null @@ -1,1889 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 -acorn-jsx@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-3.0.1.tgz#afdf9488fb1ecefc8348f6fb22f464e32a58b36b" - dependencies: - acorn "^3.0.4" - -acorn@^3.0.4: - version "3.3.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a" - -acorn@^5.2.1: - version "5.2.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.2.1.tgz#317ac7821826c22c702d66189ab8359675f135d7" - -ajv-keywords@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.1.tgz#617997fc5f60576894c435f940d819e135b80762" - -ajv@^5.2.3, ajv@^5.3.0: - version "5.4.0" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.4.0.tgz#32d1cf08dbc80c432f426f12e10b2511f6b46474" - dependencies: - co "^4.6.0" - fast-deep-equal "^1.0.0" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.3.0" - -align-text@^0.1.1, align-text@^0.1.3: - version "0.1.4" - resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" - dependencies: - kind-of "^3.0.2" - longest "^1.0.1" - repeat-string "^1.5.2" - -amdefine@>=0.0.4: - version "1.0.1" - resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" - -amqp@kfitzgerald/node-amqp#nack: - version "0.2.6" - resolved "https://codeload.github.com/kfitzgerald/node-amqp/tar.gz/d270a0774d3c4af940850ab9d9fc6b061547ac09" - dependencies: - lodash "^4.0.0" - -ansi-escapes@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.0.0.tgz#ec3e8b4e9f8064fc02c3ac9b65f1c275bda8ef92" - -ansi-regex@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" - -ansi-regex@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" - -ansi-styles@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" - -ansi-styles@^3.1.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.0.tgz#c159b8d5be0f9e5a6f346dab94f16ce022161b88" - dependencies: - color-convert "^1.9.0" - -append-transform@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/append-transform/-/append-transform-0.4.0.tgz#d76ebf8ca94d276e247a36bad44a4b74ab611991" - dependencies: - default-require-extensions "^1.0.0" - -archy@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/archy/-/archy-1.0.0.tgz#f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40" - -argparse@^1.0.7: - version "1.0.9" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.9.tgz#73d83bc263f86e97f8cc4f6bae1b0e90a7d22c86" - dependencies: - sprintf-js "~1.0.2" - -arr-diff@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf" - dependencies: - arr-flatten "^1.0.1" - -arr-flatten@^1.0.1: - version "1.1.0" - resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1" - -array-union@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" - dependencies: - array-uniq "^1.0.1" - -array-uniq@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" - -array-unique@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" - -arrify@^1.0.0, arrify@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" - -async, async@^2.6.0: - version "2.6.0" - resolved "https://registry.yarnpkg.com/async/-/async-2.6.0.tgz#61a29abb6fcc026fea77e56d1c6ec53a795951f4" - dependencies: - lodash "^4.14.0" - -async@^1.4.0: - version "1.5.2" - resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" - -babel-code-frame@^6.22.0, babel-code-frame@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" - dependencies: - chalk "^1.1.3" - esutils "^2.0.2" - js-tokens "^3.0.2" - -babel-generator@^6.18.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.26.0.tgz#ac1ae20070b79f6e3ca1d3269613053774f20dc5" - dependencies: - babel-messages "^6.23.0" - babel-runtime "^6.26.0" - babel-types "^6.26.0" - detect-indent "^4.0.0" - jsesc "^1.3.0" - lodash "^4.17.4" - source-map "^0.5.6" - trim-right "^1.0.1" - -babel-messages@^6.23.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e" - dependencies: - babel-runtime "^6.22.0" - -babel-runtime@^6.22.0, babel-runtime@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" - dependencies: - core-js "^2.4.0" - regenerator-runtime "^0.11.0" - -babel-template@^6.16.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.26.0.tgz#de03e2d16396b069f46dd9fff8521fb1a0e35e02" - dependencies: - babel-runtime "^6.26.0" - babel-traverse "^6.26.0" - babel-types "^6.26.0" - babylon "^6.18.0" - lodash "^4.17.4" - -babel-traverse@^6.18.0, babel-traverse@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee" - dependencies: - babel-code-frame "^6.26.0" - babel-messages "^6.23.0" - babel-runtime "^6.26.0" - babel-types "^6.26.0" - babylon "^6.18.0" - debug "^2.6.8" - globals "^9.18.0" - invariant "^2.2.2" - lodash "^4.17.4" - -babel-types@^6.18.0, babel-types@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497" - dependencies: - babel-runtime "^6.26.0" - esutils "^2.0.2" - lodash "^4.17.4" - to-fast-properties "^1.0.3" - -babylon@^6.18.0: - version "6.18.0" - resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3" - -balanced-match@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" - -boom@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/boom/-/boom-5.2.0.tgz#5dd9da6ee3a5f302077436290cb717d3f4a54e02" - dependencies: - hoek "4.x.x" - -brace-expansion@^1.1.7: - version "1.1.8" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292" - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -braces@^1.8.2: - version "1.8.5" - resolved "https://registry.yarnpkg.com/braces/-/braces-1.8.5.tgz#ba77962e12dff969d6b76711e914b737857bf6a7" - dependencies: - expand-range "^1.8.1" - preserve "^0.2.0" - repeat-element "^1.1.2" - -browser-stdout@1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.0.tgz#f351d32969d32fa5d7a5567154263d928ae3bd1f" - -builtin-modules@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" - -caching-transform@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/caching-transform/-/caching-transform-1.0.1.tgz#6dbdb2f20f8d8fbce79f3e94e9d1742dcdf5c0a1" - dependencies: - md5-hex "^1.2.0" - mkdirp "^0.5.1" - write-file-atomic "^1.1.4" - -caller-path@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/caller-path/-/caller-path-0.1.0.tgz#94085ef63581ecd3daa92444a8fe94e82577751f" - dependencies: - callsites "^0.2.0" - -callsites@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/callsites/-/callsites-0.2.0.tgz#afab96262910a7f33c19a5775825c69f34e350ca" - -camelcase@^1.0.2: - version "1.2.1" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39" - -camelcase@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" - -center-align@^0.1.1: - version "0.1.3" - resolved "https://registry.yarnpkg.com/center-align/-/center-align-0.1.3.tgz#aa0d32629b6ee972200411cbd4461c907bc2b7ad" - dependencies: - align-text "^0.1.3" - lazy-cache "^1.0.3" - -chalk@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" - dependencies: - ansi-styles "^2.2.1" - escape-string-regexp "^1.0.2" - has-ansi "^2.0.0" - strip-ansi "^3.0.0" - supports-color "^2.0.0" - -chalk@^2.0.0, chalk@^2.1.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.0.tgz#b5ea48efc9c1793dccc9b4767c93914d3f2d52ba" - dependencies: - ansi-styles "^3.1.0" - escape-string-regexp "^1.0.5" - supports-color "^4.0.0" - -chardet@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.0.tgz#0bbe1355ac44d7a3ed4a925707c4ef70f8190f6c" - -circular-json@^0.3.1: - version "0.3.3" - resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.3.tgz#815c99ea84f6809529d2f45791bdf82711352d66" - -cli-cursor@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5" - dependencies: - restore-cursor "^2.0.0" - -cli-width@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639" - -cliui@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-2.1.0.tgz#4b475760ff80264c762c3a1719032e91c7fea0d1" - dependencies: - center-align "^0.1.1" - right-align "^0.1.1" - wordwrap "0.0.2" - -cliui@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-3.2.0.tgz#120601537a916d29940f934da3b48d585a39213d" - dependencies: - string-width "^1.0.1" - strip-ansi "^3.0.1" - wrap-ansi "^2.0.0" - -co@^4.6.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" - -code-point-at@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" - -color-convert@^1.9.0: - version "1.9.1" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.1.tgz#c1261107aeb2f294ebffec9ed9ecad529a6097ed" - dependencies: - color-name "^1.1.1" - -color-name@^1.1.1: - version "1.1.3" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" - -commander@2.11.0: - version "2.11.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563" - -commondir@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - -concat-stream@^1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.0.tgz#0aac662fd52be78964d5532f694784e70110acf7" - dependencies: - inherits "^2.0.3" - readable-stream "^2.2.2" - typedarray "^0.0.6" - -convert-source-map@^1.3.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.5.0.tgz#9acd70851c6d5dfdd93d9282e5edf94a03ff46b5" - -cookie@0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" - -core-js@^2.4.0: - version "2.5.1" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.1.tgz#ae6874dc66937789b80754ff5428df66819ca50b" - -core-util-is@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" - -cross-spawn@^4: - version "4.0.2" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-4.0.2.tgz#7b9247621c23adfdd3856004a823cbe397424d41" - dependencies: - lru-cache "^4.0.1" - which "^1.2.9" - -cross-spawn@^5.0.1, cross-spawn@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" - dependencies: - lru-cache "^4.0.1" - shebang-command "^1.2.0" - which "^1.2.9" - -debug-log@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/debug-log/-/debug-log-1.0.1.tgz#2307632d4c04382b8df8a32f70b895046d52745f" - -debug@^2.6.8: - version "2.6.9" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" - dependencies: - ms "2.0.0" - -debug@^3.0.1, debug@^3.1.0, debug@3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" - dependencies: - ms "2.0.0" - -decamelize@^1.0.0, decamelize@^1.1.1: - version "1.2.0" - resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" - -deep-is@~0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" - -default-require-extensions@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/default-require-extensions/-/default-require-extensions-1.0.0.tgz#f37ea15d3e13ffd9b437d33e1a75b5fb97874cb8" - dependencies: - strip-bom "^2.0.0" - -del@^2.0.2: - version "2.2.2" - resolved "https://registry.yarnpkg.com/del/-/del-2.2.2.tgz#c12c981d067846c84bcaf862cff930d907ffd1a8" - dependencies: - globby "^5.0.0" - is-path-cwd "^1.0.0" - is-path-in-cwd "^1.0.0" - object-assign "^4.0.1" - pify "^2.0.0" - pinkie-promise "^2.0.0" - rimraf "^2.2.8" - -detect-indent@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-4.0.0.tgz#f76d064352cdf43a1cb6ce619c4ee3a9475de208" - dependencies: - repeating "^2.0.0" - -diff@3.3.1: - version "3.3.1" - resolved "https://registry.yarnpkg.com/diff/-/diff-3.3.1.tgz#aa8567a6eed03c531fc89d3f711cd0e5259dec75" - -doctrine@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.0.0.tgz#c73d8d2909d22291e1a007a395804da8b665fe63" - dependencies: - esutils "^2.0.2" - isarray "^1.0.0" - -error-ex@^1.2.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.1.tgz#f855a86ce61adc4e8621c3cda21e7a7612c3a8dc" - dependencies: - is-arrayish "^0.2.1" - -escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5, escape-string-regexp@1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - -eslint-scope@^3.7.1: - version "3.7.1" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8" - dependencies: - esrecurse "^4.1.0" - estraverse "^4.1.1" - -eslint@^4.10.0: - version "4.11.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.11.0.tgz#39a8c82bc0a3783adf5a39fa27fdd9d36fac9a34" - dependencies: - ajv "^5.3.0" - babel-code-frame "^6.22.0" - chalk "^2.1.0" - concat-stream "^1.6.0" - cross-spawn "^5.1.0" - debug "^3.0.1" - doctrine "^2.0.0" - eslint-scope "^3.7.1" - espree "^3.5.2" - esquery "^1.0.0" - estraverse "^4.2.0" - esutils "^2.0.2" - file-entry-cache "^2.0.0" - functional-red-black-tree "^1.0.1" - glob "^7.1.2" - globals "^9.17.0" - ignore "^3.3.3" - imurmurhash "^0.1.4" - inquirer "^3.0.6" - is-resolvable "^1.0.0" - js-yaml "^3.9.1" - json-stable-stringify-without-jsonify "^1.0.1" - levn "^0.3.0" - lodash "^4.17.4" - minimatch "^3.0.2" - mkdirp "^0.5.1" - natural-compare "^1.4.0" - optionator "^0.8.2" - path-is-inside "^1.0.2" - pluralize "^7.0.0" - progress "^2.0.0" - require-uncached "^1.0.3" - semver "^5.3.0" - strip-ansi "^4.0.0" - strip-json-comments "~2.0.1" - table "^4.0.1" - text-table "~0.2.0" - -espree@^3.5.2: - version "3.5.2" - resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.2.tgz#756ada8b979e9dcfcdb30aad8d1a9304a905e1ca" - dependencies: - acorn "^5.2.1" - acorn-jsx "^3.0.0" - -esprima@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.0.tgz#4499eddcd1110e0b218bacf2fa7f7f59f55ca804" - -esquery@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.0.0.tgz#cfba8b57d7fba93f17298a8a006a04cda13d80fa" - dependencies: - estraverse "^4.0.0" - -esrecurse@^4.1.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.2.0.tgz#fa9568d98d3823f9a41d91e902dcab9ea6e5b163" - dependencies: - estraverse "^4.1.0" - object-assign "^4.0.1" - -estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1, estraverse@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" - -esutils@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" - -execa@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/execa/-/execa-0.7.0.tgz#944becd34cc41ee32a63a9faf27ad5a65fc59777" - dependencies: - cross-spawn "^5.0.1" - get-stream "^3.0.0" - is-stream "^1.1.0" - npm-run-path "^2.0.0" - p-finally "^1.0.0" - signal-exit "^3.0.0" - strip-eof "^1.0.0" - -expand-brackets@^0.1.4: - version "0.1.5" - resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" - dependencies: - is-posix-bracket "^0.1.0" - -expand-range@^1.8.1: - version "1.8.2" - resolved "https://registry.yarnpkg.com/expand-range/-/expand-range-1.8.2.tgz#a299effd335fe2721ebae8e257ec79644fc85337" - dependencies: - fill-range "^2.1.0" - -external-editor@^2.0.4: - version "2.1.0" - resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.1.0.tgz#3d026a21b7f95b5726387d4200ac160d372c3b48" - dependencies: - chardet "^0.4.0" - iconv-lite "^0.4.17" - tmp "^0.0.33" - -extglob@^0.3.1: - version "0.3.2" - resolved "https://registry.yarnpkg.com/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1" - dependencies: - is-extglob "^1.0.0" - -fast-deep-equal@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz#96256a3bc975595eb36d82e9929d060d893439ff" - -fast-json-stable-stringify@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" - -fast-levenshtein@~2.0.4: - version "2.0.6" - resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" - -figures@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962" - dependencies: - escape-string-regexp "^1.0.5" - -file-entry-cache@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-2.0.0.tgz#c392990c3e684783d838b8c84a45d8a048458361" - dependencies: - flat-cache "^1.2.1" - object-assign "^4.0.1" - -filename-regex@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26" - -fill-range@^2.1.0: - version "2.2.3" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-2.2.3.tgz#50b77dfd7e469bc7492470963699fe7a8485a723" - dependencies: - is-number "^2.1.0" - isobject "^2.0.0" - randomatic "^1.1.3" - repeat-element "^1.1.2" - repeat-string "^1.5.2" - -find-cache-dir@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-0.1.1.tgz#c8defae57c8a52a8a784f9e31c57c742e993a0b9" - dependencies: - commondir "^1.0.1" - mkdirp "^0.5.1" - pkg-dir "^1.0.0" - -find-up@^1.0.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" - dependencies: - path-exists "^2.0.0" - pinkie-promise "^2.0.0" - -find-up@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7" - dependencies: - locate-path "^2.0.0" - -flat-cache@^1.2.1: - version "1.3.0" - resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.3.0.tgz#d3030b32b38154f4e3b7e9c709f490f7ef97c481" - dependencies: - circular-json "^0.3.1" - del "^2.0.2" - graceful-fs "^4.1.2" - write "^0.2.1" - -for-in@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" - -for-own@^0.1.4: - version "0.1.5" - resolved "https://registry.yarnpkg.com/for-own/-/for-own-0.1.5.tgz#5265c681a4f294dabbf17c9509b6763aa84510ce" - dependencies: - for-in "^1.0.1" - -foreground-child@^1.5.3, foreground-child@^1.5.6: - version "1.5.6" - resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-1.5.6.tgz#4fd71ad2dfde96789b980a5c0a295937cb2f5ce9" - dependencies: - cross-spawn "^4" - signal-exit "^3.0.0" - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - -functional-red-black-tree@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" - -get-caller-file@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.2.tgz#f702e63127e7e231c160a80c1554acb70d5047e5" - -get-stream@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" - -glob-base@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4" - dependencies: - glob-parent "^2.0.0" - is-glob "^2.0.0" - -glob-parent@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-2.0.0.tgz#81383d72db054fcccf5336daa902f182f6edbb28" - dependencies: - is-glob "^2.0.0" - -glob@^7.0.3, glob@^7.0.5, glob@^7.0.6, glob@^7.1.2, glob@7.1.2: - version "7.1.2" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -globals@^9.17.0, globals@^9.18.0: - version "9.18.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" - -globby@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/globby/-/globby-5.0.0.tgz#ebd84667ca0dbb330b99bcfc68eac2bc54370e0d" - dependencies: - array-union "^1.0.1" - arrify "^1.0.0" - glob "^7.0.3" - object-assign "^4.0.1" - pify "^2.0.0" - pinkie-promise "^2.0.0" - -graceful-fs@^4.1.11, graceful-fs@^4.1.2: - version "4.1.11" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" - -growl@1.10.3: - version "1.10.3" - resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.3.tgz#1926ba90cf3edfe2adb4927f5880bc22c66c790f" - -handlebars@^4.0.3: - version "4.0.11" - resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.11.tgz#630a35dfe0294bc281edae6ffc5d329fc7982dcc" - dependencies: - async "^1.4.0" - optimist "^0.6.1" - source-map "^0.4.4" - optionalDependencies: - uglify-js "^2.6" - -has-ansi@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" - dependencies: - ansi-regex "^2.0.0" - -has-flag@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" - -has-flag@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-2.0.0.tgz#e8207af1cc7b30d446cc70b734b5e8be18f88d51" - -he@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd" - -hoek@4.x.x: - version "4.2.0" - resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.2.0.tgz#72d9d0754f7fe25ca2d01ad8f8f9a9449a89526d" - -hosted-git-info@^2.1.4: - version "2.5.0" - resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.5.0.tgz#6d60e34b3abbc8313062c3b798ef8d901a07af3c" - -iconv-lite@^0.4.17: - version "0.4.19" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" - -ignore@^3.3.3: - version "3.3.7" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.7.tgz#612289bfb3c220e186a58118618d5be8c1bab021" - -imurmurhash@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@^2.0.3, inherits@~2.0.3, inherits@2: - version "2.0.3" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" - -inquirer@^3.0.6: - version "3.3.0" - resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-3.3.0.tgz#9dd2f2ad765dcab1ff0443b491442a20ba227dc9" - dependencies: - ansi-escapes "^3.0.0" - chalk "^2.0.0" - cli-cursor "^2.1.0" - cli-width "^2.0.0" - external-editor "^2.0.4" - figures "^2.0.0" - lodash "^4.3.0" - mute-stream "0.0.7" - run-async "^2.2.0" - rx-lite "^4.0.8" - rx-lite-aggregates "^4.0.8" - string-width "^2.1.0" - strip-ansi "^4.0.0" - through "^2.3.6" - -invariant@^2.2.2: - version "2.2.2" - resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360" - dependencies: - loose-envify "^1.0.0" - -invert-kv@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6" - -is-arrayish@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" - -is-buffer@^1.1.5: - version "1.1.6" - resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" - -is-builtin-module@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-builtin-module/-/is-builtin-module-1.0.0.tgz#540572d34f7ac3119f8f76c30cbc1b1e037affbe" - dependencies: - builtin-modules "^1.0.0" - -is-dotfile@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.3.tgz#a6a2f32ffd2dfb04f5ca25ecd0f6b83cf798a1e1" - -is-equal-shallow@^0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz#2238098fc221de0bcfa5d9eac4c45d638aa1c534" - dependencies: - is-primitive "^2.0.0" - -is-extendable@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" - -is-extglob@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0" - -is-finite@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.0.2.tgz#cc6677695602be550ef11e8b4aa6305342b6d0aa" - dependencies: - number-is-nan "^1.0.0" - -is-fullwidth-code-point@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" - dependencies: - number-is-nan "^1.0.0" - -is-fullwidth-code-point@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" - -is-glob@^2.0.0, is-glob@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-2.0.1.tgz#d096f926a3ded5600f3fdfd91198cb0888c2d863" - dependencies: - is-extglob "^1.0.0" - -is-number@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" - dependencies: - kind-of "^3.0.2" - -is-number@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" - dependencies: - kind-of "^3.0.2" - -is-path-cwd@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-1.0.0.tgz#d225ec23132e89edd38fda767472e62e65f1106d" - -is-path-in-cwd@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-path-in-cwd/-/is-path-in-cwd-1.0.0.tgz#6477582b8214d602346094567003be8a9eac04dc" - dependencies: - is-path-inside "^1.0.0" - -is-path-inside@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.0.tgz#fc06e5a1683fbda13de667aff717bbc10a48f37f" - dependencies: - path-is-inside "^1.0.1" - -is-posix-bracket@^0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4" - -is-primitive@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" - -is-promise@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" - -is-resolvable@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.0.0.tgz#8df57c61ea2e3c501408d100fb013cf8d6e0cc62" - dependencies: - tryit "^1.0.1" - -is-stream@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" - -is-utf8@^0.2.0: - version "0.2.1" - resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" - -isarray@^1.0.0, isarray@~1.0.0, isarray@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" - -isexe@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - -isobject@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" - dependencies: - isarray "1.0.0" - -istanbul-lib-coverage@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.1.1.tgz#73bfb998885299415c93d38a3e9adf784a77a9da" - -istanbul-lib-hook@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/istanbul-lib-hook/-/istanbul-lib-hook-1.1.0.tgz#8538d970372cb3716d53e55523dd54b557a8d89b" - dependencies: - append-transform "^0.4.0" - -istanbul-lib-instrument@^1.9.1: - version "1.9.1" - resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.9.1.tgz#250b30b3531e5d3251299fdd64b0b2c9db6b558e" - dependencies: - babel-generator "^6.18.0" - babel-template "^6.16.0" - babel-traverse "^6.18.0" - babel-types "^6.18.0" - babylon "^6.18.0" - istanbul-lib-coverage "^1.1.1" - semver "^5.3.0" - -istanbul-lib-report@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-1.1.2.tgz#922be27c13b9511b979bd1587359f69798c1d425" - dependencies: - istanbul-lib-coverage "^1.1.1" - mkdirp "^0.5.1" - path-parse "^1.0.5" - supports-color "^3.1.2" - -istanbul-lib-source-maps@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-1.2.2.tgz#750578602435f28a0c04ee6d7d9e0f2960e62c1c" - dependencies: - debug "^3.1.0" - istanbul-lib-coverage "^1.1.1" - mkdirp "^0.5.1" - rimraf "^2.6.1" - source-map "^0.5.3" - -istanbul-reports@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-1.1.3.tgz#3b9e1e8defb6d18b1d425da8e8b32c5a163f2d10" - dependencies: - handlebars "^4.0.3" - -js-tokens@^3.0.0, js-tokens@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" - -js-yaml@^3.9.1: - version "3.10.0" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.10.0.tgz#2e78441646bd4682e963f22b6e92823c309c62dc" - dependencies: - argparse "^1.0.7" - esprima "^4.0.0" - -jsesc@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" - -json-schema-traverse@^0.3.0: - version "0.3.1" - resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340" - -json-stable-stringify-without-jsonify@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" - -kind-of@^3.0.2: - version "3.2.2" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" - dependencies: - is-buffer "^1.1.5" - -kind-of@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57" - dependencies: - is-buffer "^1.1.5" - -lazy-cache@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e" - -lcid@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835" - dependencies: - invert-kv "^1.0.0" - -levn@^0.3.0, levn@~0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" - dependencies: - prelude-ls "~1.1.2" - type-check "~0.3.2" - -load-json-file@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" - dependencies: - graceful-fs "^4.1.2" - parse-json "^2.2.0" - pify "^2.0.0" - pinkie-promise "^2.0.0" - strip-bom "^2.0.0" - -locate-path@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" - dependencies: - p-locate "^2.0.0" - path-exists "^3.0.0" - -lodash@^4.0.0, lodash@^4.14.0, lodash@^4.17.4, lodash@^4.3.0: - version "4.17.4" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" - -longest@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" - -loose-envify@^1.0.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848" - dependencies: - js-tokens "^3.0.0" - -lru-cache@^4.0.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.1.tgz#622e32e82488b49279114a4f9ecf45e7cd6bba55" - dependencies: - pseudomap "^1.0.2" - yallist "^2.1.2" - -lsmod@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/lsmod/-/lsmod-1.0.0.tgz#9a00f76dca36eb23fa05350afe1b585d4299e64b" - -md5-hex@^1.2.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/md5-hex/-/md5-hex-1.3.0.tgz#d2c4afe983c4370662179b8cad145219135046c4" - dependencies: - md5-o-matic "^0.1.1" - -md5-o-matic@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/md5-o-matic/-/md5-o-matic-0.1.1.tgz#822bccd65e117c514fab176b25945d54100a03c3" - -mem@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/mem/-/mem-1.1.0.tgz#5edd52b485ca1d900fe64895505399a0dfa45f76" - dependencies: - mimic-fn "^1.0.0" - -merge-source-map@^1.0.2: - version "1.0.4" - resolved "https://registry.yarnpkg.com/merge-source-map/-/merge-source-map-1.0.4.tgz#a5de46538dae84d4114cc5ea02b4772a6346701f" - dependencies: - source-map "^0.5.6" - -micromatch@^2.3.11: - version "2.3.11" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565" - dependencies: - arr-diff "^2.0.0" - array-unique "^0.2.1" - braces "^1.8.2" - expand-brackets "^0.1.4" - extglob "^0.3.1" - filename-regex "^2.0.0" - is-extglob "^1.0.0" - is-glob "^2.0.1" - kind-of "^3.0.2" - normalize-path "^2.0.1" - object.omit "^2.0.0" - parse-glob "^3.0.4" - regex-cache "^0.4.2" - -mimic-fn@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.1.0.tgz#e667783d92e89dbd342818b5230b9d62a672ad18" - -minimatch@^3.0.2, minimatch@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" - dependencies: - brace-expansion "^1.1.7" - -minimist@~0.0.1: - version "0.0.10" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" - -minimist@0.0.8: - version "0.0.8" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" - -mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@0.5.1: - version "0.5.1" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" - dependencies: - minimist "0.0.8" - -mocha@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/mocha/-/mocha-4.0.1.tgz#0aee5a95cf69a4618820f5e51fa31717117daf1b" - dependencies: - browser-stdout "1.3.0" - commander "2.11.0" - debug "3.1.0" - diff "3.3.1" - escape-string-regexp "1.0.5" - glob "7.1.2" - growl "1.10.3" - he "1.1.1" - mkdirp "0.5.1" - supports-color "4.4.0" - -ms@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" - -mute-stream@0.0.7: - version "0.0.7" - resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" - -natural-compare@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" - -normalize-package-data@^2.3.2: - version "2.4.0" - resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.4.0.tgz#12f95a307d58352075a04907b84ac8be98ac012f" - dependencies: - hosted-git-info "^2.1.4" - is-builtin-module "^1.0.0" - semver "2 || 3 || 4 || 5" - validate-npm-package-license "^3.0.1" - -normalize-path@^2.0.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" - dependencies: - remove-trailing-separator "^1.0.1" - -npm-run-path@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" - dependencies: - path-key "^2.0.0" - -number-is-nan@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" - -nyc@^11.3.0: - version "11.3.0" - resolved "https://registry.yarnpkg.com/nyc/-/nyc-11.3.0.tgz#a42bc17b3cfa41f7b15eb602bc98b2633ddd76f0" - dependencies: - archy "^1.0.0" - arrify "^1.0.1" - caching-transform "^1.0.0" - convert-source-map "^1.3.0" - debug-log "^1.0.1" - default-require-extensions "^1.0.0" - find-cache-dir "^0.1.1" - find-up "^2.1.0" - foreground-child "^1.5.3" - glob "^7.0.6" - istanbul-lib-coverage "^1.1.1" - istanbul-lib-hook "^1.1.0" - istanbul-lib-instrument "^1.9.1" - istanbul-lib-report "^1.1.2" - istanbul-lib-source-maps "^1.2.2" - istanbul-reports "^1.1.3" - md5-hex "^1.2.0" - merge-source-map "^1.0.2" - micromatch "^2.3.11" - mkdirp "^0.5.0" - resolve-from "^2.0.0" - rimraf "^2.5.4" - signal-exit "^3.0.1" - spawn-wrap "=1.3.8" - test-exclude "^4.1.1" - yargs "^10.0.3" - yargs-parser "^8.0.0" - -object-assign@^4.0.1, object-assign@^4.1.0: - version "4.1.1" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" - -object.omit@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa" - dependencies: - for-own "^0.1.4" - is-extendable "^0.1.1" - -okanjo-app-broker: - version "1.0.0" - resolved "https://registry.yarnpkg.com/okanjo-app-broker/-/okanjo-app-broker-1.0.0.tgz#4bbb1d26b0522bd530cadeb3d3e7a6c1c7d7d2c0" - -okanjo-app@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/okanjo-app/-/okanjo-app-1.0.2.tgz#f4facd816c300d237949f9bc44d39b0f8af0e837" - dependencies: - async "^2.6.0" - boom "^5.2.0" - raven "^2.0.2" - -once@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - dependencies: - wrappy "1" - -onetime@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4" - dependencies: - mimic-fn "^1.0.0" - -optimist@^0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686" - dependencies: - minimist "~0.0.1" - wordwrap "~0.0.2" - -optionator@^0.8.2: - version "0.8.2" - resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64" - dependencies: - deep-is "~0.1.3" - fast-levenshtein "~2.0.4" - levn "~0.3.0" - prelude-ls "~1.1.2" - type-check "~0.3.2" - wordwrap "~1.0.0" - -os-homedir@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" - -os-locale@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-2.1.0.tgz#42bc2900a6b5b8bd17376c8e882b65afccf24bf2" - dependencies: - execa "^0.7.0" - lcid "^1.0.0" - mem "^1.1.0" - -os-tmpdir@~1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" - -p-finally@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" - -p-limit@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.1.0.tgz#b07ff2d9a5d88bec806035895a2bab66a27988bc" - -p-locate@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43" - dependencies: - p-limit "^1.1.0" - -parse-glob@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/parse-glob/-/parse-glob-3.0.4.tgz#b2c376cfb11f35513badd173ef0bb6e3a388391c" - dependencies: - glob-base "^0.3.0" - is-dotfile "^1.0.0" - is-extglob "^1.0.0" - is-glob "^2.0.0" - -parse-json@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9" - dependencies: - error-ex "^1.2.0" - -path-exists@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" - dependencies: - pinkie-promise "^2.0.0" - -path-exists@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - -path-is-inside@^1.0.1, path-is-inside@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" - -path-key@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" - -path-parse@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1" - -path-type@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" - dependencies: - graceful-fs "^4.1.2" - pify "^2.0.0" - pinkie-promise "^2.0.0" - -pify@^2.0.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" - -pinkie-promise@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" - dependencies: - pinkie "^2.0.0" - -pinkie@^2.0.0: - version "2.0.4" - resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" - -pkg-dir@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-1.0.0.tgz#7a4b508a8d5bb2d629d447056ff4e9c9314cf3d4" - dependencies: - find-up "^1.0.0" - -pluralize@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-7.0.0.tgz#298b89df8b93b0221dbf421ad2b1b1ea23fc6777" - -prelude-ls@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" - -preserve@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" - -process-nextick-args@~1.0.6: - version "1.0.7" - resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" - -progress@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f" - -pseudomap@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" - -randomatic@^1.1.3: - version "1.1.7" - resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-1.1.7.tgz#c7abe9cc8b87c0baa876b19fde83fd464797e38c" - dependencies: - is-number "^3.0.0" - kind-of "^4.0.0" - -raven@^2.0.2: - version "2.2.1" - resolved "https://registry.yarnpkg.com/raven/-/raven-2.2.1.tgz#57c7fbe68a80147ec527def3d7c01575cf948fe3" - dependencies: - cookie "0.3.1" - lsmod "1.0.0" - stack-trace "0.0.9" - timed-out "4.0.1" - uuid "3.0.0" - -read-pkg-up@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" - dependencies: - find-up "^1.0.0" - read-pkg "^1.0.0" - -read-pkg@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" - dependencies: - load-json-file "^1.0.0" - normalize-package-data "^2.3.2" - path-type "^1.0.0" - -readable-stream@^2.2.2: - version "2.3.3" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.3.tgz#368f2512d79f9d46fdfc71349ae7878bbc1eb95c" - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.3" - isarray "~1.0.0" - process-nextick-args "~1.0.6" - safe-buffer "~5.1.1" - string_decoder "~1.0.3" - util-deprecate "~1.0.1" - -regenerator-runtime@^0.11.0: - version "0.11.0" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.0.tgz#7e54fe5b5ccd5d6624ea6255c3473be090b802e1" - -regex-cache@^0.4.2: - version "0.4.4" - resolved "https://registry.yarnpkg.com/regex-cache/-/regex-cache-0.4.4.tgz#75bdc58a2a1496cec48a12835bc54c8d562336dd" - dependencies: - is-equal-shallow "^0.1.3" - -remove-trailing-separator@^1.0.1: - version "1.1.0" - resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" - -repeat-element@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.2.tgz#ef089a178d1483baae4d93eb98b4f9e4e11d990a" - -repeat-string@^1.5.2: - version "1.6.1" - resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" - -repeating@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" - dependencies: - is-finite "^1.0.0" - -require-directory@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" - -require-main-filename@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" - -require-uncached@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/require-uncached/-/require-uncached-1.0.3.tgz#4e0d56d6c9662fd31e43011c4b95aa49955421d3" - dependencies: - caller-path "^0.1.0" - resolve-from "^1.0.0" - -resolve-from@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226" - -resolve-from@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-2.0.0.tgz#9480ab20e94ffa1d9e80a804c7ea147611966b57" - -restore-cursor@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf" - dependencies: - onetime "^2.0.0" - signal-exit "^3.0.2" - -right-align@^0.1.1: - version "0.1.3" - resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef" - dependencies: - align-text "^0.1.1" - -rimraf@^2.2.8, rimraf@^2.3.3, rimraf@^2.5.4, rimraf@^2.6.1: - version "2.6.2" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" - dependencies: - glob "^7.0.5" - -run-async@^2.2.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.3.0.tgz#0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0" - dependencies: - is-promise "^2.1.0" - -rx-lite-aggregates@^4.0.8: - version "4.0.8" - resolved "https://registry.yarnpkg.com/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz#753b87a89a11c95467c4ac1626c4efc4e05c67be" - dependencies: - rx-lite "*" - -rx-lite@*, rx-lite@^4.0.8: - version "4.0.8" - resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-4.0.8.tgz#0b1e11af8bc44836f04a6407e92da42467b79444" - -safe-buffer@~5.1.0, safe-buffer@~5.1.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" - -semver@^5.3.0, "semver@2 || 3 || 4 || 5": - version "5.4.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e" - -set-blocking@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" - -shebang-command@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" - dependencies: - shebang-regex "^1.0.0" - -shebang-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" - -should-equal@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/should-equal/-/should-equal-2.0.0.tgz#6072cf83047360867e68e98b09d71143d04ee0c3" - dependencies: - should-type "^1.4.0" - -should-format@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/should-format/-/should-format-3.0.3.tgz#9bfc8f74fa39205c53d38c34d717303e277124f1" - dependencies: - should-type "^1.3.0" - should-type-adaptors "^1.0.1" - -should-type-adaptors@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/should-type-adaptors/-/should-type-adaptors-1.0.1.tgz#efe5553cdf68cff66e5c5f51b712dc351c77beaa" - dependencies: - should-type "^1.3.0" - should-util "^1.0.0" - -should-type@^1.3.0, should-type@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/should-type/-/should-type-1.4.0.tgz#0756d8ce846dfd09843a6947719dfa0d4cff5cf3" - -should-util@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/should-util/-/should-util-1.0.0.tgz#c98cda374aa6b190df8ba87c9889c2b4db620063" - -should@^13.1.3: - version "13.1.3" - resolved "https://registry.yarnpkg.com/should/-/should-13.1.3.tgz#a089bdf7979392a8272a712c8b63acbaafb7948f" - dependencies: - should-equal "^2.0.0" - should-format "^3.0.3" - should-type "^1.4.0" - should-type-adaptors "^1.0.1" - should-util "^1.0.0" - -signal-exit@^3.0.0, signal-exit@^3.0.1, signal-exit@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" - -slice-ansi@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-1.0.0.tgz#044f1a49d8842ff307aad6b505ed178bd950134d" - dependencies: - is-fullwidth-code-point "^2.0.0" - -slide@^1.1.5: - version "1.1.6" - resolved "https://registry.yarnpkg.com/slide/-/slide-1.1.6.tgz#56eb027d65b4d2dce6cb2e2d32c4d4afc9e1d707" - -source-map@^0.4.4: - version "0.4.4" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b" - dependencies: - amdefine ">=0.0.4" - -source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.1: - version "0.5.7" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" - -spawn-wrap@=1.3.8: - version "1.3.8" - resolved "https://registry.yarnpkg.com/spawn-wrap/-/spawn-wrap-1.3.8.tgz#fa2a79b990cbb0bb0018dca6748d88367b19ec31" - dependencies: - foreground-child "^1.5.6" - mkdirp "^0.5.0" - os-homedir "^1.0.1" - rimraf "^2.3.3" - signal-exit "^3.0.2" - which "^1.2.4" - -spdx-correct@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-1.0.2.tgz#4b3073d933ff51f3912f03ac5519498a4150db40" - dependencies: - spdx-license-ids "^1.0.2" - -spdx-expression-parse@~1.0.0: - version "1.0.4" - resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-1.0.4.tgz#9bdf2f20e1f40ed447fbe273266191fced51626c" - -spdx-license-ids@^1.0.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz#c9df7a3424594ade6bd11900d596696dc06bac57" - -sprintf-js@~1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" - -stack-trace@0.0.9: - version "0.0.9" - resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.9.tgz#a8f6eaeca90674c333e7c43953f275b451510695" - -string_decoder@~1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.3.tgz#0fc67d7c141825de94282dd536bec6b9bce860ab" - dependencies: - safe-buffer "~5.1.0" - -string-width@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" - dependencies: - code-point-at "^1.0.0" - is-fullwidth-code-point "^1.0.0" - strip-ansi "^3.0.0" - -string-width@^2.0.0, string-width@^2.1.0, string-width@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" - dependencies: - is-fullwidth-code-point "^2.0.0" - strip-ansi "^4.0.0" - -strip-ansi@^3.0.0, strip-ansi@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" - dependencies: - ansi-regex "^2.0.0" - -strip-ansi@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" - dependencies: - ansi-regex "^3.0.0" - -strip-bom@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" - dependencies: - is-utf8 "^0.2.0" - -strip-eof@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" - -strip-json-comments@~2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" - -supports-color@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" - -supports-color@^3.1.2: - version "3.2.3" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.2.3.tgz#65ac0504b3954171d8a64946b2ae3cbb8a5f54f6" - dependencies: - has-flag "^1.0.0" - -supports-color@^4.0.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.5.0.tgz#be7a0de484dec5c5cddf8b3d59125044912f635b" - dependencies: - has-flag "^2.0.0" - -supports-color@4.4.0: - version "4.4.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.4.0.tgz#883f7ddabc165142b2a61427f3352ded195d1a3e" - dependencies: - has-flag "^2.0.0" - -table@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/table/-/table-4.0.2.tgz#a33447375391e766ad34d3486e6e2aedc84d2e36" - dependencies: - ajv "^5.2.3" - ajv-keywords "^2.1.0" - chalk "^2.1.0" - lodash "^4.17.4" - slice-ansi "1.0.0" - string-width "^2.1.1" - -test-exclude@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-4.1.1.tgz#4d84964b0966b0087ecc334a2ce002d3d9341e26" - dependencies: - arrify "^1.0.1" - micromatch "^2.3.11" - object-assign "^4.1.0" - read-pkg-up "^1.0.1" - require-main-filename "^1.0.1" - -text-table@~0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" - -through@^2.3.6: - version "2.3.8" - resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" - -timed-out@4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/timed-out/-/timed-out-4.0.1.tgz#f32eacac5a175bea25d7fab565ab3ed8741ef56f" - -tmp@^0.0.33: - version "0.0.33" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" - dependencies: - os-tmpdir "~1.0.2" - -to-fast-properties@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" - -trim-right@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" - -tryit@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/tryit/-/tryit-1.0.3.tgz#393be730a9446fd1ead6da59a014308f36c289cb" - -type-check@~0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" - dependencies: - prelude-ls "~1.1.2" - -typedarray@^0.0.6: - version "0.0.6" - resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" - -uglify-js@^2.6: - version "2.8.29" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd" - dependencies: - source-map "~0.5.1" - yargs "~3.10.0" - optionalDependencies: - uglify-to-browserify "~1.0.0" - -uglify-to-browserify@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7" - -util-deprecate@~1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" - -uuid@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.0.tgz#6728fc0459c450d796a99c31837569bdf672d728" - -validate-npm-package-license@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz#2804babe712ad3379459acfbe24746ab2c303fbc" - dependencies: - spdx-correct "~1.0.0" - spdx-expression-parse "~1.0.0" - -which-module@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" - -which@^1.2.4, which@^1.2.9: - version "1.3.0" - resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a" - dependencies: - isexe "^2.0.0" - -window-size@0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d" - -wordwrap@~0.0.2: - version "0.0.3" - resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" - -wordwrap@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" - -wordwrap@0.0.2: - version "0.0.2" - resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" - -wrap-ansi@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85" - dependencies: - string-width "^1.0.1" - strip-ansi "^3.0.1" - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - -write-file-atomic@^1.1.4: - version "1.3.4" - resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-1.3.4.tgz#f807a4f0b1d9e913ae7a48112e6cc3af1991b45f" - dependencies: - graceful-fs "^4.1.11" - imurmurhash "^0.1.4" - slide "^1.1.5" - -write@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/write/-/write-0.2.1.tgz#5fc03828e264cea3fe91455476f7a3c566cb0757" - dependencies: - mkdirp "^0.5.1" - -y18n@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41" - -yallist@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" - -yargs-parser@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-8.0.0.tgz#21d476330e5a82279a4b881345bf066102e219c6" - dependencies: - camelcase "^4.1.0" - -yargs@^10.0.3: - version "10.0.3" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-10.0.3.tgz#6542debd9080ad517ec5048fb454efe9e4d4aaae" - dependencies: - cliui "^3.2.0" - decamelize "^1.1.1" - find-up "^2.1.0" - get-caller-file "^1.0.1" - os-locale "^2.0.0" - require-directory "^2.1.1" - require-main-filename "^1.0.1" - set-blocking "^2.0.0" - string-width "^2.0.0" - which-module "^2.0.0" - y18n "^3.2.1" - yargs-parser "^8.0.0" - -yargs@~3.10.0: - version "3.10.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.10.0.tgz#f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1" - dependencies: - camelcase "^1.0.2" - cliui "^2.1.0" - decamelize "^1.0.0" - window-size "0.1.0" -