Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

monq

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

monq

MongoDB-backed job queue for Node.js

  • 0.3.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
289
increased by34.42%
Maintainers
1
Weekly downloads
 
Created
Source

monq

Monq is a MongoDB-backed job queue for Node.js.

NPM Build Status

API Reference

Usage

Connect to MongoDB by specifying a URI or providing host, port and database options:

var monq = require('monq');
var client = monq('mongodb://localhost:27017/monq_example');

Enqueue jobs by supplying a job name and a set of parameters. Below, the job reverse is being placed into the example queue:

var queue = client.queue('example');

queue.enqueue('reverse', { text: 'foobar' }, function (err, job) {
    console.log('enqueued:', job.data);
});

Create workers to process the jobs from one or more queues. The functions responsible for performing a job must be registered with each worker:

var worker = client.worker(['example']);

worker.register({
    reverse: function (params, callback) {
        try {
            var reversed = params.text.split('').reverse().join('');
            callback(null, reversed);
        } catch (err) {
            callback(err);
        }
    }
});

worker.start();

Events

Workers will emit various events while processing jobs:

worker.on('dequeued', function (data) { … });
worker.on('failed', function (data) { … });
worker.on('complete', function (data) { … });
worker.on('error', function (err) { … });

Install

npm install monq

Tests

npm test

You can optionally specify the MongoDB URI to be used for tests:

MONGODB_URI=mongodb://localhost:27017/monq_tests npm test

Updating API documentation

npm run jsdoc2md

FAQs

Package last updated on 20 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc