Skip to content

Commit

Permalink
Merge pull request #10 from fabrix-app/v1.1
Browse files Browse the repository at this point in the history
[fix] add disable tasks config
  • Loading branch information
scott-wyatt authored Sep 5, 2018
2 parents ee83946 + 906adb8 commit 8b4fc62
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 14 deletions.
13 changes: 12 additions & 1 deletion lib/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ export const Engine = {
*/
buildTasker: (app: FabrixApp) => {
let taskerConfig = app.config.get('engine.tasks_config')

if (taskerConfig.enabled === false) {
return Promise.resolve()
}

const profileName = app.config.get('engine.profile')
const profile = Utils.getWorkerProfile(profileName, taskerConfig)
taskerConfig = Utils.configureExchangesAndQueues(profile, taskerConfig)
Expand All @@ -221,7 +226,13 @@ export const Engine = {
* Add Tasks to Rabbit
*/
addTasks: (app: FabrixApp) => {
rabbit.configure(app.config.get('engine.tasks_config'))
let taskerConfig = app.config.get('engine.tasks_config')

if (taskerConfig.enabled === false) {
return Promise.resolve()
}

rabbit.configure(taskerConfig)
return Promise.resolve()
},

Expand Down
28 changes: 17 additions & 11 deletions lib/config/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,36 @@ export const engine = {
auto_save: false,
profile: process.env.ENGINE_PROFILE || null,
crons_config: {
enabled: true,
auto_schedule: true,
uptime_delay: process.env.CRON_UPTIME_DELAY || 0
uptime_delay: process.env.ENGINE_CRON_UPTIME_DELAY || 0,
profiles: {}
},
events_config: {
auto_subscribe: true
enabled: true,
auto_subscribe: true,
profiles: {}
},
tasks_config: {
enabled: true,
auto_que: true,
connection: {
// optional, defaults to `tasks-work-x`
exchange: 'tasks-work-x', // process.env.TASK_EXCHANGE,
exchange: process.env.ENGINE_TASK_EXCHANGE,
// optional, defaults to `tasks-work-q`
work_queue_name: 'tasks-work-q', // process.env.TASK_WORK_QUEUE,
work_queue_name: process.env.ENGINE_TASK_WORK_QUEUE,
// optional, defaults to `tasks-interrupt-q`
interrupt_queue_name: 'tasks-interrupt-q', // process.env.TASK_INTERRUPT_QUEUE,
interrupt_queue_name: process.env.ENGINE_TASK_INTERRUPT_QUEUE,

/**
* The RabbitMQ connection information.
* See: https://www.rabbitmq.com/uri-spec.html
*/
host: process.env.TASK_RMQ_HOST,
user: process.env.TASK_RMQ_USER,
pass: process.env.TASK_RMQ_PASS,
port: process.env.TASK_RMQ_PORT,
vhost: process.env.TASK_RMQ_VHOST,
host: process.env.ENGINE_TASK_RMQ_HOST,
user: process.env.ENGINE_TASK_RMQ_USER,
pass: process.env.ENGINE_TASK_RMQ_PASS,
port: process.env.ENGINE_TASK_RMQ_PORT,
vhost: process.env.ENGINE_TASK_RMQ_VHOST,

/**
* Connection information could also be passed via uri
Expand All @@ -47,6 +52,7 @@ export const engine = {
timeout: null, // this is the connection timeout (in milliseconds, per connection attempt), and there is no default
failAfter: 60, // limits how long rabbot will attempt to connect (in seconds, across all connection attempts). Defaults to 60
retryLimit: 3, // limits number of consecutive failed attempts
}
},
profiles: {}
}
}
3 changes: 3 additions & 0 deletions lib/schemas/engineConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ export const engineConfig = joi.object().keys({
profile: joi.string().allow(null).required(),
// Cron Job Config
crons_config: joi.object().keys({
enabled: joi.boolean(),
auto_schedule: joi.boolean(),
uptime_delay: joi.number(),
profiles: joi.object().pattern(/^/, joi.array().items(joi.string().regex(/(.+)\.(.+)/)))
}),
// Events Config
events_config: joi.object().keys({
enabled: joi.boolean(),
auto_subscribe: joi.boolean(),
profiles: joi.object().pattern(/^/, joi.array().items(joi.string().regex(/(.+)\.(.+)/)))
}),
// Tasks Config
tasks_config: joi.object().keys({
enabled: joi.boolean(),
auto_que: joi.boolean(),
// profiles: joi.object().pattern(/^/, joi.array().items(joi.string().regex(/(.+)\.(.+)/))),
profiles: joi.object().pattern(/^/, joi.array().items(joi.string())),
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fabrix/spool-engine",
"version": "1.1.7",
"version": "1.1.8",
"description": "Spool - Emitter Engine for Fabrix",
"homepage": "https://fabrix.app",
"author": {
Expand Down

0 comments on commit 8b4fc62

Please sign in to comment.