simple_scheduler 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a609cbea37bbbcfc43aa830039a3b89ab2467bf9
4
- data.tar.gz: a4bafa4c6c324a4dd75e0b5b4cb49076a4313d40
3
+ metadata.gz: ff28ce865f99e1cb0a04b2f8d1ece60998e1a096
4
+ data.tar.gz: 1416ef9bbb7296fb2db35030f5cd2811c5667303
5
5
  SHA512:
6
- metadata.gz: a5eb15d2033392fb29a3305bd81485fe940a673f55583e0aaaa0c5bf0f029c52570c80c399ca05ffc5f94d9820144f62f8fa245fd02a76ae4087846f66a7802f
7
- data.tar.gz: 8a5807630dc3881df1810a299540f67226c81a6973556972f7944b50c906b9b42790168c0593ce3bb385214db414d8ee41664a8559ca486985531dfea50f7dc4
6
+ metadata.gz: 385b890ba17e8acdcaac2560fa34a67aee4341a38f91ed30b92bc26ad6c54c9b9a492740bbbb32447196236b168beae4ed1b8a2c07a10b80b17e8809988ce684
7
+ data.tar.gz: 9ab1dff5976d4272bb7097cde27fa105fa1dbd792a1f06843955965c48ee3e1e56c3fa2b83930a3ed86272189d8add425096adfb09dc02b3ccd2114ace1b1daf
data/README.md CHANGED
@@ -12,6 +12,17 @@ gives you the ability to **schedule tasks at any interval** without adding
12
12
  a clock process. Heroku Scheduler only allows you to schedule tasks every 10 minutes,
13
13
  every hour, or every day.
14
14
 
15
+ ## Production Ready?
16
+
17
+ **Yes.** We are using Simple Scheduler in production for scheduling hourly,
18
+ nightly, and weekly tasks in [Simple In/Out](https://www.simpleinout.com).
19
+
20
+ ### Why did we need to create yet another job scheduler?
21
+
22
+ Every option we evaluated seems to have the same flaw: **If your server is down, your job won't run.**
23
+
24
+ [Check out our intro blog post to learn more](http://www.simplymadeapps.com/blog/2017/01/simple-scheduler-schedule-recurring-tasks-to-run-at-any-interval/).
25
+
15
26
  ## Requirements
16
27
 
17
28
  You must be using:
@@ -43,9 +54,9 @@ $ bundle
43
54
  Create the file `config/simple_scheduler.yml` in your Rails project:
44
55
 
45
56
  ```yml
46
- # Global configuration options and their defaults. These can also be set on each task.
57
+ # Global configuration options. These can also be set on each task.
47
58
  queue_ahead: 360 # Number of minutes to queue jobs into the future
48
- tz: nil # The application time zone will be used by default
59
+ tz: "America/Chicago" # The application time zone will be used by default if not set
49
60
 
50
61
  # Runs once every 2 minutes
51
62
  simple_task:
@@ -60,7 +71,7 @@ overnight_task:
60
71
  at: "4:00"
61
72
  expires_after: "23.hours"
62
73
 
63
- # Runs once every hour at the half hour
74
+ # Runs once every half hour, starting on the 30 min mark
64
75
  half_hour_task:
65
76
  class: "HalfHourTask"
66
77
  every: "30.minutes"
@@ -71,7 +82,7 @@ weekly_task:
71
82
  class: "WeeklyJob"
72
83
  every: "1.week"
73
84
  at: "Sat 0:00"
74
- tz: "America/Chicago"
85
+ tz: "America/New_York"
75
86
  ```
76
87
 
77
88
  ### Set up Heroku Scheduler
@@ -208,78 +219,6 @@ If you're using a custom configuration file:
208
219
  rake simple_scheduler:reset["config/simple_scheduler.staging.yml"]
209
220
  ```
210
221
 
211
- ## How It Works
212
-
213
- The Heroku Scheduler must be set up to run `rake simple_scheduler` every 10 minutes.
214
- The rake task will load the configuration file each time and ensure that each task has
215
- jobs scheduled for the future. This is done by checking the `Sidekiq::ScheduledSet`.
216
-
217
- A minimum of two jobs is always added to the scheduled set. By default all
218
- jobs for the next six hours are queued in advance. This ensures that there is
219
- always one job in the queue that can be used to determine the next run time,
220
- even if one of the two was executed during the 10 minute scheduler wait time.
221
-
222
- ### Server Downtime Example
223
-
224
- If you're using a gem like [clockwork](https://github.com/Rykian/clockwork),
225
- there is no way for the clock process to know that the task was never run.
226
- If your task is scheduled for `12:00:00`, your clock process could possibly
227
- be restarted at `11:59:59` and your dyno might not be available until `12:00:20`.
228
-
229
- Simple Scheduler would have already enqueued the task hours before the task should actually
230
- run, so you still have to worry about the worker dyno restarting, but when the worker
231
- dyno becomes available, the enqueued task will be there and will be executed immediately.
232
-
233
- ### Daily Digest Email Example
234
-
235
- Here's an example of a daily digest email that needs to go out at 8:00 AM for
236
- users in their local time zone. We need to run this every 15 minutes to handle
237
- all time zone offsets.
238
-
239
- config/simple_scheduler.yml:
240
-
241
- ```yml
242
- # Runs every hour starting at the top of the hour + every 15 minutes
243
- daily_digest_task:
244
- class: "DailyDigestEmailJob"
245
- every: "15.minutes"
246
- at: "*:00"
247
- expires_after: "23.hours"
248
- ```
249
-
250
- app/jobs/daily_digest_email_job.rb:
251
-
252
- ```ruby
253
- class DailyDigestEmailJob < ApplicationJob
254
- queue_as :default
255
-
256
- # Called by Simple Scheduler and is given the scheduled time so decisions can be made
257
- # based on when the job was scheduled to be run rather than when it was actually run.
258
- # @param scheduled_time [Integer] The epoch time for when the job was scheduled to be run
259
- def perform(scheduled_time)
260
- # Don't do this! This will be way too slow!
261
- User.find_each do |user|
262
- if user.digest_time == Time.at(scheduled_time)
263
- DigestMailer.daily(user).deliver_later
264
- end
265
- end
266
- end
267
- end
268
- ```
269
-
270
- app/models/user.rb:
271
-
272
- ```ruby
273
- class User < ApplicationRecord
274
- # Returns the time the user's daily digest should be
275
- # delivered today based on the user's time zone.
276
- # @return [Time]
277
- def digest_time
278
- "8:00 AM".in_time_zone(self.time_zone)
279
- end
280
- end
281
- ```
282
-
283
222
  ## Contributing
284
223
 
285
224
  1. Fork it
@@ -22,9 +22,9 @@ module SimpleScheduler
22
22
  # "[Sun|Mon|Tue|Wed|Thu|Fri|Sat] 00:00"
23
23
  # @param at [String] The formatted string for a task's run time
24
24
  # @param time_zone [ActiveSupport::TimeZone] The time zone to parse the at time in
25
- def initialize(at, time_zone = Time.zone)
25
+ def initialize(at, time_zone = nil)
26
26
  @at = at
27
- @time_zone = time_zone
27
+ @time_zone = time_zone || Time.zone
28
28
  super(parsed_time.year, parsed_time.month, parsed_time.day,
29
29
  parsed_time.hour, parsed_time.min, parsed_time.sec, parsed_time.utc_offset)
30
30
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleScheduler
2
- VERSION = "0.2.4".freeze
2
+ VERSION = "0.2.5".freeze
3
3
  end
metadata CHANGED
@@ -1,139 +1,139 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_scheduler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Pattison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-27 00:00:00.000000000 Z
11
+ date: 2017-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sidekiq
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '4.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '4.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: appraisal
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: codeclimate-test-reporter
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rainbow
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: 2.1.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: 2.1.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec-rails
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rubocop
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - '>='
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: simplecov
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - '>='
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: simplecov-rcov
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">="
129
+ - - '>='
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ">="
136
+ - - '>='
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  description: |2
@@ -146,17 +146,17 @@ executables: []
146
146
  extensions: []
147
147
  extra_rdoc_files: []
148
148
  files:
149
- - MIT-LICENSE
150
- - README.md
151
- - Rakefile
152
- - lib/simple_scheduler.rb
153
149
  - lib/simple_scheduler/at.rb
154
150
  - lib/simple_scheduler/future_job.rb
155
151
  - lib/simple_scheduler/railtie.rb
156
152
  - lib/simple_scheduler/scheduler_job.rb
157
153
  - lib/simple_scheduler/task.rb
158
154
  - lib/simple_scheduler/version.rb
155
+ - lib/simple_scheduler.rb
159
156
  - lib/tasks/simple_scheduler_tasks.rake
157
+ - MIT-LICENSE
158
+ - Rakefile
159
+ - README.md
160
160
  homepage: https://github.com/simplymadeapps/simple_scheduler
161
161
  licenses:
162
162
  - MIT
@@ -167,17 +167,17 @@ require_paths:
167
167
  - lib
168
168
  required_ruby_version: !ruby/object:Gem::Requirement
169
169
  requirements:
170
- - - ">="
170
+ - - '>='
171
171
  - !ruby/object:Gem::Version
172
172
  version: '0'
173
173
  required_rubygems_version: !ruby/object:Gem::Requirement
174
174
  requirements:
175
- - - ">="
175
+ - - '>='
176
176
  - !ruby/object:Gem::Version
177
177
  version: '0'
178
178
  requirements: []
179
179
  rubyforge_project:
180
- rubygems_version: 2.5.1
180
+ rubygems_version: 2.0.14.1
181
181
  signing_key:
182
182
  specification_version: 4
183
183
  summary: An enhancement for Heroku Scheduler + Sidekiq for scheduling jobs at specific