smart_jobs

0.0.5 • Public • Published

Smart Jobs

This is a small wrapper over messagehub.js that adds queue callbacks for jobs.

example use:

var image_processing_hub = hub(args.rabbitmq,'simple.image.processing');
var image_processing_job = smart_job(image_processing_hub,'process pdf');
var image_processing_done = smart_job(image_processing_hub,'done with doc');

in the above example we create a hub via message hub, this sets the rabbitMQ config and gives our messages a namespace of 'simple.image.processing'

when we create a smart job image_processing_job it generates further name spaces 'process pdf' and 'finished process pdf'

Posting Jobs

image_processing_done.post(job);

the above is an example of what one would do when they want to post a job. in this case the job is being posted to 'done with doc' queue in the 'simple.image.processing. name-space.

Working on Jobs

image_processing_job
  .worker(function(job,done){...})

setting up a worker is just like message hub, minus the name-space. the done function takes a response message that is sent to the issuer of the job.

Responding to finished Jobs

image_processing_job
     .response(function(job_response,done){...});

The response is used when listening to a finished job. The job_response argument is sent via the worker that finished the job. otherwise .response is the same as .worker except that it's done callback doesn't take arguments.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.5
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.5
    1
  • 0.0.4
    1
  • 0.0.3
    1
  • 0.0.2
    1
  • 0.0.1
    1

Package Sidebar

Install

npm i smart_jobs

Weekly Downloads

5

Version

0.0.5

License

none

Last publish

Collaborators

  • pppaul