kof / node-mongo-queue Goto Github PK
View Code? Open in Web Editor NEWNode.js job queue backed by MongoDB
Node.js job queue backed by MongoDB
When polling for new tasks it often happens that there's no matches for the find() part of findandmodify()
Older versions of the driver just returned null
, newer return a MongoError
with errmsg
='No matching object found'. In order to make mojo work with recent versions of the driver we have to handle that case in the callback passed to Connection.next()
inside Worker.poll
. In JS:
if (err != null && err.errmsg !== 'No matching object found') {
this.emit('error', err);
}
Thanks! :)
Hello Tomas !
I've discovered mojo recently and I must say I've been quite impressed with the work you have done !
I was on my way to test it a bit and I was wondering if you (or anyone reading this) had some figures or real world uses of it that could give me hints on what kind of performance to expect from such solution.
Do you think it could handle a massive amount of jobs (~10k) in a decent time (< 5 mins) ? Across a cluster of mongodbs ?
Regards.
Hi @kof,
I've pushed updates to make this module work with the new mongodb 2.0 module.
Since I don't have the publish rights can you do it ?
Also can you see if it's possible to enable travis ? I've already added the configuration file, it should be straightforward.
Thanks.
Hi,
I'd like to engage in a breaking change in the library but before doing that I thought it would be clever to discuss that.
I think the template should be responsible for its parameters, which would allow to override per job, by that I mean an API like that :
class Addition extends queue.Template
# Default values for that template
@expires = 5000
@maxAttempts = 20
perform: (a, b) ->
console.log a + ' + ' + b + ' = ' + (a + b)
@complete()
addition = new Addition(1, 1)
addition.expires = 10000
addition.maxAttempts = 10
connection.enqueue addition
What do you think ?
cleanup() takes queue
and callback
as arguments but does not use queue
in the function body.
For folks (like me) trying out mojo on some hosted environment / PaaS being able to use an authenticated connection to Mongo would be very helpful.
Without knowing any CoffeeScript I tried this, which even sort of helped:
new mongodb.Db(opt.db, server, {}).open (err, db) =>
db.authenticate opt.username, opt.password, (err) =>
db.collection 'mojo', (err, collection) =>
@mojo = collection
...
Hi,
I need to set up tasks for a later time, I think the current code can't handle non-immediate tasks, would you accept a PR for that ?
That might depend (and be easier with) #9.
Ideally by passing in a set of mongodb:// urls plus options
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.