Skip to content

Commit f3ac1ce

Browse files
committed
4.3.2 bug fix for new Meteor versions
1 parent 5172b31 commit f3ac1ce

File tree

3 files changed

+152
-2
lines changed

3 files changed

+152
-2
lines changed

package/README.md

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
<img align="right" width="220" src="https://github.com/msavin/stevejobs/blob/master/ICON.png?raw=true" />
2+
3+
# Steve Jobs
4+
5+
### The Simple Jobs Queue That Just Works
6+
7+
Run scheduled tasks with Steve Jobs, the simple jobs queue made just for Meteor. With tight MongoDB integration and fibers-based timing functions, this package is quick, reliable and effortless to use.
8+
9+
- Jobs run on one server at a time
10+
- Jobs run predictably and consecutively
11+
- Jobs, their history and returned data are stored in MongoDB
12+
- Failed jobs are retried on server restart
13+
- No third party dependencies
14+
15+
**The new 4.0 features repeating jobs, async support and more!** It can run hundreds of jobs in seconds with minimal CPU impact, making it a reasonable choice for many applications. To get started, check out the <a href="https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md">**documentation**</a> and the <a href="#quick-start">**quick start**</a> below.
16+
17+
## Developer Friendly GUI and API
18+
19+
<img src="https://github.com/msavin/SteveJobs...meteor.schedule.background.tasks.jobs.queue/blob/master/GUI.png?raw=true">
20+
21+
In addition to a simple API, the Steve Jobs package offers an in-app development tool. After installing the main package, run the package command below and press Control + J in your app to open it.
22+
23+
```
24+
meteor add msavin:sjobs-ui-blaze
25+
```
26+
27+
Note: this package may be a little bit flakey, and might not work if `audit-argument-checks` is present. Unfortunately, I had lost the source code, and will probably rebuild the package once there is a good reason to do so.
28+
29+
## Quick Start
30+
31+
First, install the package, and import if necessary:
32+
33+
```bash
34+
meteor add msavin:sjobs
35+
```
36+
37+
```javascript
38+
import { Jobs } from 'meteor/msavin:sjobs'
39+
```
40+
41+
Then, write your background jobs like you would write your methods:
42+
43+
```javascript
44+
Jobs.register({
45+
"sendReminder": function (to, message) {
46+
const instance = this;
47+
48+
const call = HTTP.put("http://www.magic.com/email/send", {
49+
to: to,
50+
message: message,
51+
subject: "You've Got Mail!",
52+
})
53+
54+
if (call.statusCode !== 200) {
55+
instance.reschedule({
56+
in: {
57+
minutes: 5
58+
}
59+
});
60+
} else {
61+
return call.data;
62+
}
63+
}
64+
});
65+
```
66+
67+
Finally, schedule a background job like you would call a method:
68+
69+
```javascript
70+
Jobs.run("sendReminder", "[email protected]", "The future is here!");
71+
```
72+
73+
One more thing: the function above will schedule the job to run on the moment that the function was called, however, you can delay it by passing in a special <a href="https://github.com/msavin/SteveJobs-meteor-jobs-queue/wiki#configuration-options">**configuration object**</a> at the end:
74+
75+
```javascript
76+
Jobs.run("sendReminder", "[email protected]", "The future is here!", {
77+
in: {
78+
days: 3,
79+
},
80+
on: {
81+
hour: 9,
82+
minute: 42
83+
},
84+
priority: 9999999999
85+
});
86+
```
87+
88+
The configuration object supports `date`, `in`, `on`, `priority`, `singular`, `unique`, and `data`, all of which are completely optional. For more information, see the `Jobs.run` <a href="https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobsrun">documentation</a>.
89+
90+
## Repeating Jobs
91+
92+
Compared to a CRON Job, the Steve Jobs package gives you much more control over how and when the job runs. To get started, you just need to create a job that replicates itself.
93+
94+
```javascript
95+
Jobs.register({
96+
"syncData": function () {
97+
const instance = this;
98+
const call = HTTP.put("http://www.magic.com/syncData")
99+
100+
if (call.statusCode === 200) {
101+
instance.replicate({
102+
in: {
103+
hours: 1
104+
}
105+
});
106+
107+
// to save storage, you can remove the document
108+
instance.remove();
109+
} else {
110+
instance.reschedule({
111+
in: {
112+
minutes: 5
113+
}
114+
});
115+
}
116+
}
117+
});
118+
```
119+
120+
Then, you need to "kickstart" the queue by creating the first job to run. By using the singular flag, you can ensure that Meteor will only create the job if there is no pending or failed instance of it.
121+
122+
```javascript
123+
Meteor.startup(function () {
124+
Jobs.run("syncData", {
125+
singular: true
126+
})
127+
})
128+
```
129+
130+
## Documentation
131+
132+
`Jobs.register` and `Jobs.run` are all you need to get started, but that's only the beginning of what the package can do. To explore the rest of the functionality, jump into the documentation:
133+
- [Jobs.configure](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobsconfigure)
134+
- [Jobs.register](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobsregister)
135+
- [Jobs.run](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobsrun)
136+
- [Jobs.execute](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobsexecute)
137+
- [Jobs.reschedule](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobsreschedule)
138+
- [Jobs.replicate](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobsreplicate)
139+
- [Jobs.start](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobsstart)
140+
- [Jobs.stop](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobsstop)
141+
- [Jobs.get](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobsget)
142+
- [Jobs.cancel](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobscancel)
143+
- [Jobs.clear](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobsclear)
144+
- [Jobs.remove](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobsremove)
145+
- [Jobs.collection](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobscollection)
146+
147+
------
148+
149+
Steve Jobs is an MIT-licensed project, brought to you by [**Meteor Candy**](https://www.meteorcandy.com/?ref=sjgh).

package/package.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package.describe({
22
name: "msavin:sjobs",
33
summary: "The simple jobs queue that just works [synced, schedule, tasks, background, later, worker, cron]",
4-
version: "4.3.1",
4+
version: "4.3.2",
55
documentation: "README.md",
66
git: "https://github.com/msavin/SteveJobs.git",
77
});

package/server/imports/utilities/collection/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { Mongo } from "meteor/mongo"
22
import { config } from "../config"
33

4+
let collection;
5+
46
const initializeCollection = function () {
57
if (config.remoteCollection) {
68
const dbDriver = new MongoInternals.RemoteCollectionDriver(config.remoteCollection);
@@ -9,7 +11,6 @@ const initializeCollection = function () {
911
collection = new Mongo.Collection(config.collectionName);
1012
}
1113

12-
1314
if (collection.createIndex) {
1415
collection.createIndex({ due: 1, state: 1 });
1516
} else {

0 commit comments

Comments
 (0)