Comments (5)
Last week, I tried to make a PR adding some config features like setting the collection name and I found in the way the collection is created here: this runs before the main app is run.
Why commenting this here? Because implementing the package in an OOP style would solve both things: settings could be passed when creating the main object and then, the start function would be called. Also, you could create several object instances if you want to run multiple jobs at the same time.
Something like this:
queue1 = new JobQueue({
collectionName: 'my-job-collection',
timer: 5 * 1000,
startupDelay: 5 * 1000,
activityDelay: 5 * 60 * 1000
});
queue1.addJob(...);
queue1.addJob(...);
queue2 = new JobQueue({
collectionName: 'my-job-collection',
timer: 10 * 1000,
startupDelay: 10 * 1000,
activityDelay: 10 * 60 * 1000
});
queue2.addJob(...);
queue2.addJob(...);
// in case it makes sense, the start makes sense, the start/stop functions could be called juts manually instead of automatically:
queue1.start();
For example: I have a custom nightQueue that runs the same jobs every night and it gets started by queue1 every night. If I don't need something like that, I only use one global instance of the JobQueue.
What do you think about moving implementation to OOP?
from stevejobs.
@luixal I like the idea of allowing different collection names to be set, could be handy for debugging too. As for going all OOP, I'm not sure if it would be worth it, and the package is OOP-ish as is. What I really like is that you can just write Jobs.register({...})
and Jobs.run({...})
from anywhere in your app and expect things to work.
from stevejobs.
In other news, the package was just re-implemented to start an instance of JobsRunner for each registered queue. This means that Jobs now runs multiple queues simultaneously, while keeping the one job at a time approach with-in each queue.
I'm enjoying this approach because:
- jobs run in order and predictably.
- you can still run through thousands of jobs quickly and easily
- cpu impact is minimal
I wonder, maybe this could be a nice distinction of the package? or should we ultimately try to run multiple jobs simultaneously across multiple servers?
from stevejobs.
I wonder, maybe this could be a nice distinction of the package? or should we ultimately try to run multiple jobs simultaneously across multiple servers?
Not sure about this. I think that running across multiple servers implies to have a state control (or some kind of locks) to avoid different instances running the same job at the same time.
Right now, I'm not sure how would I implement something like this based in Meteor. My first approach would be kind a singleton: a common job dispatcher that runs jobs in different runners across instances.
from stevejobs.
Quick update on this: the 2.0 is out, and with it, all the functions relating to how jobs are executed are in the operator
folder, so maybe in the future, we can upgrade it. For now, I will close this ticket as it relates to the 1.0 release.
from stevejobs.
Related Issues (20)
- List of available jobs to be run HOT 5
- Self is not defined error in 4.2.0 HOT 1
- Jobs Stuck Pending on Galaxy HOT 3
- server/imports/utilities/collection/index.js --> Cannot read property 'parent' of null HOT 4
- Prevent queue from stopping after failure HOT 8
- How to resume pending jobs when the server is restarted? HOT 1
- Missing index?
- Meteor 3.0 support (Fibers-free)
- Jobs.find not part of Atmosphere package HOT 4
- So what is the date format that's valid HOT 1
- Collection hooks HOT 1
- Version 3 causing rendering issue on instagram browser on iPhone HOT 2
- Possible to convert this to a pure Node.js package removing Meteor? HOT 3
- jobs are not run consecutively HOT 2
- Jobs: Unable to execute job - queue is busy: HOT 6
- V3.1.1 - Job runner stopped, jobs are not running anymore HOT 13
- Jobs: Unable to execute job - queue is busy, randomly appearing. HOT 2
- async / await Failure HOT 7
- Know if a queue is still processed HOT 2
- work with meteor 2.3 ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stevejobs.