![]() |
4 vuotta sitten | |
---|---|---|
.. | ||
.editorconfig | 4 vuotta sitten | |
.gitignore | 4 vuotta sitten | |
.jshintrc | 4 vuotta sitten | |
.travis.yml | 4 vuotta sitten | |
LICENSE.md | 4 vuotta sitten | |
README.md | 4 vuotta sitten | |
api.md | 4 vuotta sitten | |
internal.api.md | 4 vuotta sitten | |
package.js | 4 vuotta sitten | |
power-queue.js | 4 vuotta sitten | |
spinal-queue.spec.md | 4 vuotta sitten | |
tests.js | 4 vuotta sitten |
Looking for maintainers - please reach out!
This package is to be archived due to inability to find contributors, thanks to everyone who helped make it possible.
If you're looking for an alternative, we highly recommend Meteor-Files by VeliovGroup
PowerQueue is a native Meteor package for memory-backed job queue processing. Features include:
PowerQueue can use one of two spinal-queue packages, ReactiveList or MicroQueue.
Check out the cool live queue demo and live sub queue example.
Source code for both can be found in the two branches of the power-queue-example repo.
Kind regards,
Eric(@aldeed) and Morten(@raix)
Happy coding!
All getters and setters are reactive.
function(done)
, can be overwritten var queue = new PowerQueue({
isPaused: true
});
queue.add(function(done) {
console.log('task 1');
done();
});
queue.add(function(done) {
console.log('task 2');
done();
});
queue.add(function(done) {
console.log('task 3');
done();
});
console.log('Ready to run queue');
queue.run();
This is a very rough example of how to make custom task handling.
queue.errorHandler = function(data, addTask) {
// This error handler lets the task drop, but we could use addTask to
// Put the task into the queue again
tasks.update({ _id: data.id }, { $set: { status: 'error'} });
};
queue.taskHandler = function(data, next) {
// The task is now processed...
tasks.update({ _id: data.id }, { $set: { status: 'processing'} });
Meteor.setTimeout(function() {
if (Math.random() > 0.5) {
// We random fail the task
tasks.update({ _id: data.id }, { $set: { status: 'failed'} });
// Returning error to next
next('Error: Fail task');
} else {
// We are done!
tasks.update({ _id: data.id }, { $set: { status: 'done'} });
// Trigger next task
next();
}
// This async task duration is between 500 - 1000ms
}, Math.round(500 + 500 * Math.random()));
};
// Add the task:
var taskId = 0;
queue.add({ id: tasks.insert({ status: 'added', index: ++taskId }) });
Here's the complete API documentation, including private methods.
To update the docs, run npm install docmeteor
then docmeteor
.