chore: rename module to elastiq

This commit is contained in:
2017-08-08 19:34:48 -07:00
parent 170ba3b8a0
commit 83a0352202
8 changed files with 40 additions and 40 deletions

View File

@@ -4,6 +4,7 @@ Notable changes to the esqueue project. Pay attention to `[BREAKING]` changes wh
## v3.0.0
- rename to elastiq
- support for node v4 or earlier is no longer tested
- update several dependencies
- fix issue where job poller would not wait for ES response

View File

@@ -1,6 +1,6 @@
{
"name": "esqueue",
"version": "2.0.2",
"name": "elastiq",
"version": "3.0.0",
"description": "Job queue, powered by Elasticsearch",
"main": "lib/index.js",
"scripts": {
@@ -10,7 +10,7 @@
"test": "retire -n -p package.json && npm run build && npm run unit",
"unit": "nyc --require babel-core/register mocha test/src/**"
},
"author": "Elastic (https://github.com/elastic)",
"author": "Joe Fleming (https://github.com/w33ble)",
"keywords": [
"job",
"queue",
@@ -19,7 +19,7 @@
],
"repository": {
"type": "git",
"url": "https://github.com/elastic/esqueue.git"
"url": "https://github.com/w33ble/elastiq.git"
},
"license": "Apache-2.0",
"engines": {

View File

@@ -1,10 +1,12 @@
[![Build Status](https://travis-ci.org/w33ble/esqueue.svg?branch=master)](https://travis-ci.org/w33ble/esqueue)
[![Apache License](https://img.shields.io/badge/license-apache_2.0-a9215a.svg)](https://raw.githubusercontent.com/w33ble/esqueue/master/LICENSE)
[![Project Status](https://img.shields.io/badge/status-experimental-orange.svg)](https://github.com/w33ble/esqueue#project-status)
[![Build Status](https://travis-ci.org/w33ble/elastiq.svg?branch=master)](https://travis-ci.org/w33ble/elastiq)
[![Apache License](https://img.shields.io/badge/license-apache_2.0-a9215a.svg)](https://raw.githubusercontent.com/w33ble/elastiq/master/LICENSE)
[![Project Status](https://img.shields.io/badge/status-experimental-orange.svg)](https://github.com/w33ble/elastiq#project-status)
# esqueue
# elastiq
`esqueue` is an Elasticsearch-powered job queue. This is not supported by Elastic.
`elastiq` is an Elasticsearch-powered job queue.
Pronounced Elasti-queue. This is not supported by Elastic.
## Project Status
@@ -14,20 +16,17 @@ While it's believed to be pretty stable, this library isn't really being used an
Version | Elasticsearch Version
------- | ---------------------
2.x + | 5.x +
0.x-1.x | 2.x-4.x
3.x + | 5.x +
`npm install esqueue`
`npm install elastiq`
If you are working with an older version of Elasticsearch, you need it to work with an older version of esqueue. For example:
`npm install esqueue@^1.0.0`
If you are working with an older version of Elasticsearch, consider using `esqueue`.
## Usage
Simply include the module in your application.
`var Esqueue = require('esqueue');`
`var elastiq = require('elastiq');`
### Creating a queue
@@ -37,7 +36,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 Esqueue(index, options);
var queue = new Elastiq(index, options);
```
The queue instance is an event emitter, so you can listen for `error` events as you would any other event emitter.
@@ -49,7 +48,7 @@ Option | Default | Description
interval | `week` | Valid choices are `year`, `month`, `week`, `day`, `hour`, and even `minute`. | `week`
dateSeparator | `-` | Separator for the formatted date, *YYYY-MM-DD* for example, in the index pattern.
timeout | `10000` | The default job timeout, in `ms`. If workers take longer than this, the job is re-queued for another worker to complete it.
doctype | `esqueue` | The doctype to use in Elasticsearch
doctype | `elastiq` | The doctype to use in Elasticsearch
indexSettings | | Specify which `settings` to pass on index creation. See the [Elasticsearch index creation docs](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/indices-create-index.html) for more info.
client | | Options to use when creating a new client instance - see [the elasticsearch-js docs](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/configuration.html). If you rather use your own client instance, just pass it in here instead.
@@ -159,15 +158,15 @@ All of the above are valid. `workerFn2` and `asyncWorker` are likely to be more
## Queue events
`esqueue` components, namely the Queue, Job, and Worker instances, are also event emitters. Each instance will emit events to help your application know when certain things happen in the queue, like when a job is created, or a worker is done running, or when it times out.
`elastiq` components, namely the Queue, Job, and Worker instances, are also event emitters. Each instance will emit events to help your application know when certain things happen in the queue, like when a job is created, or a worker is done running, or when it times out.
It's important to note that all events emitted from the Job and Worker instances are also emitted on the Queue instance. This means that your application should be able to react to changes by only keeping track of that instance.
Available events can be found in `lib/constants/events.js`, and you're encouraged to import and use those constant values in your application. Here's an example:
```js
var Queue = require('esqueue');
var queueEvents = require('esqueue/lib/constants/events');
var Queue = require('elastiq');
var queueEvents = require('elastiq/lib/constants/events');
var jobQueue = new Queue('my-index');

View File

@@ -2,5 +2,5 @@ export default {
DEFAULT_SETTING_TIMEOUT: 10000,
DEFAULT_SETTING_DATE_SEPARATOR: '-',
DEFAULT_SETTING_INTERVAL: 'week',
DEFAULT_SETTING_DOCTYPE: 'esqueue',
DEFAULT_SETTING_DOCTYPE: 'elastiq',
};

View File

@@ -7,9 +7,9 @@ import indexTimestamp from './helpers/index_timestamp';
import objectOmit from './helpers/object_omit';
import logger from './helpers/logger';
const debug = logger('esqueue:queue');
const debug = logger('elastiq:queue');
export default class Esqueue extends events.EventEmitter {
export default class Elastiq extends events.EventEmitter {
constructor(index, options = {}) {
if (!index) throw new Error('Must specify an index to write to');

View File

@@ -5,7 +5,7 @@ import logger from './helpers/logger';
import createIndex from './helpers/create_index';
import isPlainObject from './helpers/is_plain_object';
const debug = logger('esqueue:job');
const debug = logger('elastiq:job');
const puid = new Puid();
export default class Job extends events.EventEmitter {

View File

@@ -6,7 +6,7 @@ import logger from './helpers/logger';
import { WorkerTimeoutError, UnspecifiedWorkerError } from './helpers/errors';
const puid = new Puid();
const debug = logger('esqueue:worker');
const debug = logger('elastiq:worker');
function formatJobObject(job) {
return {

View File

@@ -8,12 +8,12 @@ import elasticsearchMock from '../fixtures/elasticsearch';
import jobMock from '../fixtures/job';
import workerMock from '../fixtures/worker';
const Esqueue = proxyquire.noPreserveCache()('../../lib/index', {
const Queue = proxyquire.noPreserveCache()('../../lib/index', {
'./job.js': jobMock,
'./worker.js': workerMock,
});
describe('Esqueue class', function () {
describe('Elastiq class', function () {
let client;
beforeEach(function () {
@@ -21,18 +21,18 @@ describe('Esqueue class', function () {
});
it('should be an event emitter', function () {
const queue = new Esqueue('esqueue', { client });
const queue = new Queue('elastiq', { client });
expect(queue).to.be.an(events.EventEmitter);
});
describe('Option validation', function () {
it('should throw without an index', function () {
const init = () => new Esqueue();
const init = () => new Queue();
expect(init).to.throwException(/must.+specify.+index/i);
});
it('should throw with an invalid host', function () {
const init = () => new Esqueue('esqueue', {
const init = () => new Queue('elastiq', {
client: { host: 'nope://nope' }
});
@@ -40,7 +40,7 @@ describe('Esqueue class', function () {
});
it('should throw with invalid hosts', function () {
const init = () => new Esqueue('esqueue', {
const init = () => new Queue('elastiq', {
client: { hosts: [{ host: 'localhost', protocol: 'nope' }] }
});
@@ -51,7 +51,7 @@ describe('Esqueue class', function () {
describe('Queue construction', function () {
it('should ping the ES server', function () {
const pingSpy = sinon.spy(client, 'ping');
new Esqueue('esqueue', { client });
new Queue('elastiq', { client });
sinon.assert.calledOnce(pingSpy);
});
});
@@ -63,14 +63,14 @@ describe('Esqueue class', function () {
let queue;
beforeEach(function () {
indexName = 'esqueue-index';
indexName = 'elastiq-index';
jobType = 'test-test';
payload = { payload: true };
queue = new Esqueue(indexName, { client });
queue = new Queue(indexName, { client });
});
it('should throw with invalid dateSeparator setting', function () {
queue = new Esqueue(indexName, { client, dateSeparator: 'a' });
queue = new Queue(indexName, { client, dateSeparator: 'a' });
const fn = () => queue.addJob(jobType, payload);
expect(fn).to.throwException();
});
@@ -97,7 +97,7 @@ describe('Esqueue class', function () {
}
};
queue = new Esqueue(indexName, { client, indexSettings });
queue = new Queue(indexName, { client, indexSettings });
const job = queue.addJob(jobType, payload);
expect(job.getProp('options')).to.have.property('indexSettings', indexSettings);
});
@@ -117,7 +117,7 @@ describe('Esqueue class', function () {
let queue;
beforeEach(function () {
queue = new Esqueue('esqueue', { client });
queue = new Queue('elastiq', { client });
});
it('should keep track of workers', function () {
@@ -146,7 +146,7 @@ describe('Esqueue class', function () {
doctype: 'tests'
};
queue = new Esqueue('esqueue', { client });
queue = new Queue('elastiq', { client });
const worker = queue.registerWorker('type', noop, workerOptions);
expect(worker.getProp('options')).to.equal(workerOptions);
});
@@ -154,7 +154,7 @@ describe('Esqueue class', function () {
describe('Destroy', function () {
it('should destroy workers', function () {
const queue = new Esqueue('esqueue', { client });
const queue = new Queue('elastiq', { client });
const stubs = times(3, () => { return { destroy: sinon.stub() }; });
stubs.forEach((stub) => queue._workers.push(stub));
expect(queue.getWorkers()).to.have.length(3);