From 5efccc4435957da3b5f1c21ba2bf98afe575e0d7 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Tue, 3 May 2016 16:30:54 -0700 Subject: [PATCH] rename project to esqueue --- package.json | 8 ++++++-- readme.md | 16 +++++++++++----- src/index.js | 2 +- test/src/index.js | 18 +++++++++--------- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 5c54c03..c4c3cee 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "elastique", + "name": "esqueue", "version": "0.1.0", "description": "", "main": "lib/index.js", @@ -10,7 +10,11 @@ "test": "npm run build && npm run unit", "unit": "nyc --require babel-core/register mocha test/src/**" }, - "author": "", + "author": "Joe Fleming (https://github.com/w33ble)", + "repository": { + "type": "git", + "url": "https://github.com/w33ble/esqueue.git" + }, "license": "Apache-2.0", "engines": { "node": ">=4.3.0" diff --git a/readme.md b/readme.md index 0d3997c..ad2b444 100644 --- a/readme.md +++ b/readme.md @@ -1,12 +1,18 @@ -[![Build Status](https://travis-ci.org/w33ble/elastique.svg?branch=master)](https://travis-ci.org/w33ble/elastique) [![codecov](https://codecov.io/gh/w33ble/elastique/branch/master/graph/badge.svg)](https://codecov.io/gh/w33ble/elastique) +[![Build Status](https://travis-ci.org/w33ble/esqueue.svg?branch=master)](https://travis-ci.org/w33ble/esqueue) [![codecov](https://codecov.io/gh/w33ble/esqueue/branch/master/graph/badge.svg)](https://codecov.io/gh/w33ble/esqueue) -# Elasticsearch-powered job queue +# esqueue -WIP, working title +`esqueue` is an Elasticsearch-powered job queue + +## Installation + +`npm install esqueue` ## Usage -Still not ready for publishing to npm... +Simply include the module in your application. + +`var Esqueue = require('esqueue');` ### Creating a queue @@ -16,7 +22,7 @@ The first step is to create a new Queue instance. This is your point of entry, i var index = 'my-index'; var options = {}; -var queue = new Elastique(index, options); +var queue = new Esqueue(index, options); ``` The queue instance is an event emitter, so you can listen for `error` events as you would any other event emitter. diff --git a/src/index.js b/src/index.js index e04b2ee..42bb608 100644 --- a/src/index.js +++ b/src/index.js @@ -8,7 +8,7 @@ import { omit } from 'lodash'; const debug = logger('queue'); -export default class Elastique extends events.EventEmitter { +export default class Esqueue extends events.EventEmitter { constructor(index, options = {}) { if (!index) throw new Error('Must specify an index to write to'); diff --git a/test/src/index.js b/test/src/index.js index e007b59..ed99984 100644 --- a/test/src/index.js +++ b/test/src/index.js @@ -3,9 +3,9 @@ import expect from 'expect.js'; import sinon from 'sinon'; import { noop, times } from 'lodash'; import elasticsearchMock from '../fixtures/elasticsearch'; -import Elastique from '../../lib/index'; +import Esqueue from '../../lib/index'; -describe('Elastique class', function () { +describe('Esqueue class', function () { let client; beforeEach(function () { @@ -13,18 +13,18 @@ describe('Elastique class', function () { }); it('should be an event emitter', function () { - const queue = new Elastique('elastique', { client }); + const queue = new Esqueue('esqueue', { client }); expect(queue).to.be.an(events.EventEmitter); }); describe('Option validation', function () { it('should throw without an index', function () { - const init = () => new Elastique(); + const init = () => new Esqueue(); expect(init).to.throwException(/must.+specify.+index/i); }); it('should throw with an invalid host', function () { - const init = () => new Elastique('elastique', { + const init = () => new Esqueue('esqueue', { client: { host: 'nope://nope' } }); @@ -32,7 +32,7 @@ describe('Elastique class', function () { }); it('should throw with invalid hosts', function () { - const init = () => new Elastique('elastique', { + const init = () => new Esqueue('esqueue', { client: { hosts: [{ host: 'localhost', protocol: 'nope' }] } }); @@ -43,14 +43,14 @@ describe('Elastique class', function () { describe('Queue construction', function () { it('should ping the ES server', function () { const pingSpy = sinon.spy(client, 'ping'); - new Elastique('elastique', { client }); + new Esqueue('esqueue', { client }); sinon.assert.calledOnce(pingSpy); }); }); describe('Registering workers', function () { it('should keep track of workers', function () { - const queue = new Elastique('elastique', { client }); + const queue = new Esqueue('esqueue', { client }); expect(queue.getWorkers()).to.eql([]); expect(queue.getWorkers()).to.have.length(0); @@ -63,7 +63,7 @@ describe('Elastique class', function () { describe('Destroy', function () { it('should destroy workers', function () { - const queue = new Elastique('elastique', { client }); + const queue = new Esqueue('esqueue', { client }); const stubs = times(3, () => { return { destroy: sinon.stub() }; }); stubs.forEach((stub) => queue._workers.push(stub)); expect(queue.getWorkers()).to.have.length(3);