diff --git a/lib/Engine.ts b/lib/Engine.ts index f2ce9cb..e573a76 100755 --- a/lib/Engine.ts +++ b/lib/Engine.ts @@ -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) @@ -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() }, diff --git a/lib/config/engine.ts b/lib/config/engine.ts index 93aaa3e..51cb8c3 100755 --- a/lib/config/engine.ts +++ b/lib/config/engine.ts @@ -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 @@ -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: {} } } diff --git a/lib/schemas/engineConfig.ts b/lib/schemas/engineConfig.ts index 973b166..de8c68d 100755 --- a/lib/schemas/engineConfig.ts +++ b/lib/schemas/engineConfig.ts @@ -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())), diff --git a/package-lock.json b/package-lock.json index b235a4d..d417186 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@fabrix/spool-engine", - "version": "1.1.7", + "version": "1.1.8", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 8dfbc2f..6c5770e 100755 --- a/package.json +++ b/package.json @@ -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": {