use contants for defaults, use a common doctype

add tests, update readme
This commit is contained in:
2016-05-12 11:47:05 -07:00
parent fa784393e5
commit 0020050f3f
6 changed files with 48 additions and 20 deletions

View File

@@ -6,4 +6,10 @@ export const jobStatuses = {
JOB_STATUS_CANCELLED: 'cancelled',
};
export default Object.assign({}, jobStatuses);
export const defaultSettings = {
DEFAULT_SETTING_TIMEOUT: 10000,
DEFAULT_SETTING_INTERVAL: 'week',
DEFAULT_SETTING_DOCTYPE: 'esqueue',
};
export default Object.assign({}, jobStatuses, defaultSettings);

View File

@@ -1,3 +1,5 @@
import { defaultSettings } from './constants';
const schema = {
payload: { type: 'object', enabled: false },
priority: { type: 'short' },
@@ -19,14 +21,9 @@ const schema = {
}
};
export default function createIndex(client, indexName) {
const indexBody = {
mappings: {
_default_: {
properties: schema
}
}
};
export default function createIndex(client, indexName, doctype = defaultSettings.DEFAULT_SETTING_DOCTYPE) {
const indexBody = { mappings : {} };
indexBody.mappings[doctype] = { properties: schema };
return client.indices.exists({
index: indexName,