
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600× Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
node-queue
Advanced tools
Node-queue is a node.js module for multiple databases. It can be very useful if you work with (d)ddd, cqrs, eventsourcing, commands and events, etc.
Node-queue is a node.js module for multiple databases. It can be very useful if you work with (d)ddd, cqrs, eventsourcing, commands and events, etc.
$ npm install node-queue
var queue = require('node-queue');
queue.createQueue(function(err, myQueue) {
if(err) {
console.log('ohhh :-(');
return;
}
// you can now use myQueue variable to go on...
});
Make shure you have installed the required driver, in this example run: 'npm install mongodb'.
var queue = require('node-queue');
queue.createQueue(
{
type: 'mongoDb',
host: 'localhost', // optional
port: 27017, // optional
dbName: 'queuedb', // optional
collectionName: 'queue' // optional
timeout: 10000 // optional
},
function(err, myQueue) {
if(err) {
console.log('ohhh :-(');
return;
}
// you can now use myQueue variable to go on...
}
);
myQueue.push('myId', { some: 'data' }, function(err) {
if(err) {
console.log('ohhh :-(');
return;
}
});
myQueue.remove('myId', function(err) {
if(err) {
console.log('ohhh :-(');
return;
}
});
myQueue.isQueued('myId', function(err, isQueued) {
if(isQueued) {
console.log('Already queued!');
} else {
console.log('Not queued!');
}
});
myQueue.getAll(function(err, items) {
if(err) {
console.log('ohhh :-(');
return;
}
// items is an array of all what is in the queue
var firstItem = items[0];
console.log('the id: ' + firstItem.id);
console.log('the pushed data: ' + firstItem.data);
});
myQueue.getNewId(function(err, newId) {
if(err) {
console.log('ohhh :-(');
return;
}
console.log('the new id is: ' + newId);
});
var q = queue.createQueue({ type: 'mongodb' }, function(err, q) {
console.log('hello from callback');
// use queue here...
});
q.on('connect', function() {
console.log('hello from event');
// or here
});
q.on('disconnect', function() {
console.log('bye');
});
// if you push yout items with a workers property...
myQueue.push('myId', { some: 'data', workers: 2 }, function(err) {
if(err) {
console.log('ohhh :-(');
return;
}
});
...
// then you can decrement the workers property
myQueue.decrement('myId', function(err, hasBeenRemoved) {
if(err) {
console.log('ohhh :-(');
return;
}
// Now the workers value is decremented,
// but if the workers value after the decrement is 0,
// the record will be automatically removed.
// You can check this with the flag hasBeenRemoved!
if(hasBeenRemoved) {
console.log('All workers finished!');
}
});
Currently these databases are supported:
You can use your own db implementation by extending this... (pass the Queue as type in the options)
var Queue = require('node-queue').Queue,
util = require('util'),
_ = require('lodash');
function MyDB(options) {
Queue.call(this, options);
}
util.inherits(MyDB, Queue);
_.extend(MyDB.prototype, {
...
});
module.exports = MyDB;
Copyright (c) 2015 Adriano Raiano
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Node-queue is a node.js module for multiple databases. It can be very useful if you work with (d)ddd, cqrs, eventsourcing, commands and events, etc.
The npm package node-queue receives a total of 7 weekly downloads. As such, node-queue popularity was classified as not popular.
We found that node-queue 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
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.