move constants to lib root

This commit is contained in:
2016-07-11 11:20:44 -07:00
parent 27390fef44
commit c6986e3677
12 changed files with 32 additions and 30 deletions

View File

@@ -0,0 +1,5 @@
export default {
DEFAULT_SETTING_TIMEOUT: 10000,
DEFAULT_SETTING_INTERVAL: 'week',
DEFAULT_SETTING_DOCTYPE: 'esqueue',
};

View File

@@ -1,18 +1,4 @@
export const jobStatuses = {
JOB_STATUS_PENDING: 'pending',
JOB_STATUS_PROCESSING: 'processing',
JOB_STATUS_COMPLETED: 'completed',
JOB_STATUS_FAILED: 'failed',
JOB_STATUS_CANCELLED: 'cancelled',
};
export const defaultSettings = {
DEFAULT_SETTING_TIMEOUT: 10000,
DEFAULT_SETTING_INTERVAL: 'week',
DEFAULT_SETTING_DOCTYPE: 'esqueue',
};
export const events = {
export default {
EVENT_QUEUE_ERROR: 'error',
EVENT_JOB_CREATED: 'job:created',
EVENT_JOB_ERROR: 'job:error',
@@ -21,9 +7,8 @@ export const events = {
EVENT_WORKER_JOB_CLAIM_ERROR: 'worker:claim job error',
EVENT_WORKER_JOB_SEARCH_ERROR: 'worker:pending jobs error',
EVENT_WORKER_JOB_UPDATE_ERROR: 'worker:update job error',
EVENT_WORKER_JOB_FAIL: 'worker:job failed',
EVENT_WORKER_JOB_FAIL_ERROR: 'worker:failed job update error',
EVENT_WORKER_JOB_EXECUTION_ERROR: 'worker:job execution error',
EVENT_WORKER_JOB_TIMEOUT_ERROR: 'worker:job timeout',
};
export default Object.assign({}, jobStatuses, defaultSettings, events);

5
src/constants/index.js Normal file
View File

@@ -0,0 +1,5 @@
import events from './events';
import statuses from './statuses';
import defaultSettings from './default_settings';
export default Object.assign({}, events, statuses, defaultSettings);

View File

@@ -0,0 +1,7 @@
export default {
JOB_STATUS_PENDING: 'pending',
JOB_STATUS_PROCESSING: 'processing',
JOB_STATUS_COMPLETED: 'completed',
JOB_STATUS_FAILED: 'failed',
JOB_STATUS_CANCELLED: 'cancelled',
};

View File

@@ -1,4 +1,4 @@
import { defaultSettings } from './constants';
import { DEFAULT_SETTING_DOCTYPE } from '../constants';
const schema = {
jobtype: { type: 'string', index: 'not_analyzed' },
@@ -22,7 +22,7 @@ const schema = {
}
};
export default function createIndex(client, indexName, doctype = defaultSettings.DEFAULT_SETTING_DOCTYPE, settings = {}) {
export default function createIndex(client, indexName, doctype = DEFAULT_SETTING_DOCTYPE, settings = {}) {
const indexBody = { mappings : {} };
indexBody.mappings[doctype] = { properties: schema };

View File

@@ -1,11 +1,11 @@
import events from 'events';
import omit from 'lodash.omit';
import Job from './job.js';
import Worker from './worker.js';
import constants from './constants';
import createClient from './helpers/es_client';
import indexTimestamp from './helpers/index_timestamp';
import logger from './helpers/logger';
import constants from './helpers/constants';
import Job from './job.js';
import Worker from './worker.js';
import omit from 'lodash.omit';
const debug = logger('esqueue:queue');

View File

@@ -1,8 +1,8 @@
import events from 'events';
import isPlainObject from 'lodash.isplainobject';
import Puid from 'puid';
import contstants from './constants';
import logger from './helpers/logger';
import contstants from './helpers/constants';
import createIndex from './helpers/create_index';
const debug = logger('esqueue:job');

View File

@@ -1,8 +1,8 @@
import events from 'events';
import Puid from 'puid';
import moment from 'moment';
import constants from './constants';
import logger from './helpers/logger';
import constants from './helpers/constants';
import { WorkerTimeoutError, UnspecifiedWorkerError } from './helpers/errors';
const puid = new Puid();