Hapi.js plugin and client module/executable to handle queueing and scheduling of background jobs.
Installation
Install via NPM
npm install mobeeus
You will also need to install RabbitMQ and MongoDB.
Documentation
Example
This example produces
> node ./index & mobeeus -f ./worker.js [46385] Hello from the Worker.[46380] Hello from the Server.
index.js
'use strict'; // Load modulesconst Hapi = ;const Hoek = ;const Mobeeus = ; const Simple = ;const Server = ; const server = ;server; const mobeeus = register: Mobeeus options: // Register the two queues on the server. register: Simple Server // State can be an object or a function that returns // an object. State is provided as the 'context' to // a task or a job. { return ; } ; // Register the plugin.server;
worker.js
'use strict'; // Load modulesconst Simple = ;const Server = ; exports = moduleexports = register: Simple Server { return ; };
queues/simple.js
'use strict'; // Load modules const Joi = ;const Process = ; exports = module { // Define the queue. mobeeus; // Define a task that uses the queue. mobeeus;};
queues/server.js
'use strict'; // Load modules const Joi = ;const Process = ; exports = module { // Define a 'server' queue. Meaning server consumes tasks. mobeeus; // Define a task that will run on the server. mobeeus;};