Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Message Queue for Node.js and MongoDB
var k = require('koda')
, mongodb = require('mongodb')
mongodb.MongoClient.connect('mongodb://localhost/test', function(err, db) {
if (err || !db) {
console.error('failed to connect to db', err, db);
process.exit(1);
}
var koda = k.create(db);
koda.on('ready', function() {
console.log('koda ready');
koda.enqueue('job_a', { blabla: true }, function(err, data) {
console.log('enqueue job_a callback', err, data);
});
koda.enqueue('job_b', { oops: true }, { expires: 5000 /*milliseconds*/, ignoreResult: true }, function(err, data) {
console.log('enqueue job_b callback', err, data);
});
});
koda.on('error', function(err) {
console.error('coda init failed', err, err.stack);
process.exit(1);
});
function print_queue_stats() {
koda.stats(function (err, result) {
console.log(err, result);
setTimeout(print_queue_stats, 5000) ;
})
}
print_queue_stats()
});
var k = require('koda')
, mongodb = require('mongodb')
mongodb.MongoClient.connect('mongodb://localhost/test', function(err, db) {
if (err || !db) {
console.error('failed to connect to db', err, db);
process.exit(1);
}
var koda = k.create(db);
koda.on('error', function (err) {
console.error('queue has problems, check database', err)
process.exit(1)
})
koda.on('ready', function () {
// "requeues" jobs that were in assigned state in case of an unexpected restart
koda.requeueStale(['job_a', 'job_b'], function (err, result) {
function next_job_a() {
// blocks while new job doesn't arrive
koda.next('job_a',function(event, finish) {
console.log('got job A event', event);
finish(null); // marks jobs as completed (null) or failed (!null)
next_job_a();
});
}
function next_job_b() {
// blocks while new job doesn't arrive
koda.next('job_b',function(event, finish) {
console.log('got job B event', event);
finish(null);
next_job_b();
});
}
next_job_a();
next_job_b();
})
})
});
FAQs
Message Queue for Node.js and MongoDB
We found that koda demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.