-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple collections or types, need to understand this... #228
Comments
Hi, a lot of questions in there... I'll try to quickly answer the big ones:
In this code: let taskQueue = myJobCollection.processJobs(workerName, {
// ... A handle to the worker queue for each "type" is being returned. But you aren't storing it anywhere accessible so it can be acted on in the future. If you instead did: taskQueues[workerName] = myJobCollection.processJobs(workerName, {
// ... Then you can do things to that worker's/jobType's queue, like pause it. taskQueues['sendEmail'].pause() Note that this is pausing the worker which is different from pausing jobs on the server (preventing them from being assigned to a worker) which is what the sample app UI you looked at does. You can find docs for the worker queue API here: https://github.com/vsivsi/meteor-job-collection#jobqueue-api
A jobCollection is just a collection. You can publish queries on that collection (say by jobType) and subscribe to those publications in the client.
From your own code: function(job, callback) {
// ... The worker function is called with two things, a Your code invokes the callback in the catch block: job.fail(err.message);
callback(); But nowhere else. Every
job-collection has extensive documentation and two sample apps. Yes they are written in Coffeescript, but they work. I'm always willing to accept PRs that make the documentation more complete/clearer. Hope that helps. |
http://decaffeinate-project.org/repl |
So I am writing a platform in where we create
Tasks
that can do whatever, from send an email to download stuff.What I am doing is creating a
processJobs
for eachtask
with a given name (all this serverside using Meteor)And adding new Job
This creates a MongoDB collection
queue.jobs
and adds Documents (jobs) every time I add a new Job, that means I end up with the following3 types
sendEmail
,downloadFiles
,sendFiles
Each type has its own jobs, that's OK.
But how do I stop a type from being executed? For example, I want to stop sending emails, how do I stop
sendEmail
from pulling documents from MongoDB and doing the logic?How can I create an UI (well that's easy tho) but getting a list of
types
and their current jobs? BecausesendEmail
can be running for 100 jobs simultaneously, and I want to see how many they have and so...The documentation isn't very clear to me, the example provided (playground) is fully written in Coffeescript (easy to read but could be good to have a pure JS example) and isn't very clear about how things work... and everything is managed via clientside, with one file only storing every variable instead of separating client for server using ES6 with Imports and such, and it's complicated to do what I need to do...
Should I create a new
JobCollection
for eachTask
and run only oneprocessJobs
for each, instead what I am doing? That could be a mess too if I need to list all the workers and their status, relaunch and so...And what the hell is calback inside
processJobs
if I am not passing any callback, but doc says ALWAYS call it?I am so lost in here atm...
The text was updated successfully, but these errors were encountered: