rename project to esqueue
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "elastique",
|
"name": "esqueue",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
@@ -10,7 +10,11 @@
|
|||||||
"test": "npm run build && npm run unit",
|
"test": "npm run build && npm run unit",
|
||||||
"unit": "nyc --require babel-core/register mocha test/src/**"
|
"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",
|
"license": "Apache-2.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=4.3.0"
|
"node": ">=4.3.0"
|
||||||
|
|||||||
16
readme.md
16
readme.md
@@ -1,12 +1,18 @@
|
|||||||
[](https://travis-ci.org/w33ble/elastique) [](https://codecov.io/gh/w33ble/elastique)
|
[](https://travis-ci.org/w33ble/esqueue) [](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
|
## Usage
|
||||||
|
|
||||||
Still not ready for publishing to npm...
|
Simply include the module in your application.
|
||||||
|
|
||||||
|
`var Esqueue = require('esqueue');`
|
||||||
|
|
||||||
### Creating a queue
|
### 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 index = 'my-index';
|
||||||
var options = {};
|
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.
|
The queue instance is an event emitter, so you can listen for `error` events as you would any other event emitter.
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { omit } from 'lodash';
|
|||||||
|
|
||||||
const debug = logger('queue');
|
const debug = logger('queue');
|
||||||
|
|
||||||
export default class Elastique extends events.EventEmitter {
|
export default class Esqueue extends events.EventEmitter {
|
||||||
constructor(index, options = {}) {
|
constructor(index, options = {}) {
|
||||||
if (!index) throw new Error('Must specify an index to write to');
|
if (!index) throw new Error('Must specify an index to write to');
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ import expect from 'expect.js';
|
|||||||
import sinon from 'sinon';
|
import sinon from 'sinon';
|
||||||
import { noop, times } from 'lodash';
|
import { noop, times } from 'lodash';
|
||||||
import elasticsearchMock from '../fixtures/elasticsearch';
|
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;
|
let client;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
@@ -13,18 +13,18 @@ describe('Elastique class', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be an event emitter', 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);
|
expect(queue).to.be.an(events.EventEmitter);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Option validation', function () {
|
describe('Option validation', function () {
|
||||||
it('should throw without an index', function () {
|
it('should throw without an index', function () {
|
||||||
const init = () => new Elastique();
|
const init = () => new Esqueue();
|
||||||
expect(init).to.throwException(/must.+specify.+index/i);
|
expect(init).to.throwException(/must.+specify.+index/i);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw with an invalid host', function () {
|
it('should throw with an invalid host', function () {
|
||||||
const init = () => new Elastique('elastique', {
|
const init = () => new Esqueue('esqueue', {
|
||||||
client: { host: 'nope://nope' }
|
client: { host: 'nope://nope' }
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ describe('Elastique class', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should throw with invalid hosts', function () {
|
it('should throw with invalid hosts', function () {
|
||||||
const init = () => new Elastique('elastique', {
|
const init = () => new Esqueue('esqueue', {
|
||||||
client: { hosts: [{ host: 'localhost', protocol: 'nope' }] }
|
client: { hosts: [{ host: 'localhost', protocol: 'nope' }] }
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -43,14 +43,14 @@ describe('Elastique class', function () {
|
|||||||
describe('Queue construction', function () {
|
describe('Queue construction', function () {
|
||||||
it('should ping the ES server', function () {
|
it('should ping the ES server', function () {
|
||||||
const pingSpy = sinon.spy(client, 'ping');
|
const pingSpy = sinon.spy(client, 'ping');
|
||||||
new Elastique('elastique', { client });
|
new Esqueue('esqueue', { client });
|
||||||
sinon.assert.calledOnce(pingSpy);
|
sinon.assert.calledOnce(pingSpy);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Registering workers', function () {
|
describe('Registering workers', function () {
|
||||||
it('should keep track of 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.eql([]);
|
||||||
expect(queue.getWorkers()).to.have.length(0);
|
expect(queue.getWorkers()).to.have.length(0);
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ describe('Elastique class', function () {
|
|||||||
|
|
||||||
describe('Destroy', function () {
|
describe('Destroy', function () {
|
||||||
it('should destroy workers', 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() }; });
|
const stubs = times(3, () => { return { destroy: sinon.stub() }; });
|
||||||
stubs.forEach((stub) => queue._workers.push(stub));
|
stubs.forEach((stub) => queue._workers.push(stub));
|
||||||
expect(queue.getWorkers()).to.have.length(3);
|
expect(queue.getWorkers()).to.have.length(3);
|
||||||
|
|||||||
Reference in New Issue
Block a user