simple_scheduler 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/simple_scheduler/task.rb +9 -9
- data/lib/simple_scheduler/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b71b4f5c3e484c52baefe6f0a7bb053190cdd0a0
|
4
|
+
data.tar.gz: b24a48c76cd13c18c175bd6cf43dafd2beb45632
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba009c0d2a0565a03ffcee90c92e69de5cec1aab98f22ec523cee894bc7d200c05229053bebfef02ff9283213002a21f1d1db96ac1aa5b91d5d762f9c349173d
|
7
|
+
data.tar.gz: 2ee4e84837c33e00e3d6b2648446ee7cb6d4ecbb6462b20b6cd96acf41e2c26d655c9daa446749cc1a9857ca6c3d3e84de20335580da4b803b2fe0a7c1f0f3fa
|
data/README.md
CHANGED
@@ -162,7 +162,9 @@ a job wasn't run because it expires. Add this block to an initializer file:
|
|
162
162
|
```ruby
|
163
163
|
# config/initializers/simple_scheduler.rb
|
164
164
|
|
165
|
+
# Block for handling an expired task from Simple Scheduler
|
165
166
|
# @param exception [SimpleScheduler::FutureJob::Expired]
|
167
|
+
# @see http://www.rubydoc.info/github/simplymadeapps/simple_scheduler/master/SimpleScheduler/FutureJob/Expired
|
166
168
|
SimpleScheduler.expired_task do |exception|
|
167
169
|
ExceptionNotifier.notify_exception(
|
168
170
|
exception,
|
@@ -2,23 +2,23 @@ module SimpleScheduler
|
|
2
2
|
# Class for parsing each task in the scheduler config YAML file and returning
|
3
3
|
# the values needed to schedule the task in the future.
|
4
4
|
#
|
5
|
-
# @!attribute at
|
5
|
+
# @!attribute [r] at
|
6
6
|
# @return [String] The starting time for the interval
|
7
|
-
# @!attribute expires_after
|
7
|
+
# @!attribute [r] expires_after
|
8
8
|
# @return [String] The time between the scheduled and actual run time that should cause the job not to run
|
9
|
-
# @!attribute frequency
|
9
|
+
# @!attribute [r] frequency
|
10
10
|
# @return [ActiveSupport::Duration] How often the job will be run
|
11
11
|
# @!attribute [r] job_class
|
12
12
|
# @return [Class] The class of the job or worker
|
13
13
|
# @!attribute [r] job_class_name
|
14
14
|
# @return [String] The class name of the job or worker
|
15
|
-
# @!attribute name
|
15
|
+
# @!attribute [r] name
|
16
16
|
# @return [String] The name of the task as defined in the YAML config
|
17
17
|
# @!attribute [r] params
|
18
18
|
# @return [Hash] The params used to create the task
|
19
|
-
# @!attribute queue_ahead
|
19
|
+
# @!attribute [r] queue_ahead
|
20
20
|
# @return [String] The name of the task as defined in the YAML config
|
21
|
-
# @!attribute time_zone
|
21
|
+
# @!attribute [r] time_zone
|
22
22
|
# @return [ActiveSupport::TimeZone] The time zone to use when parsing the `at` option
|
23
23
|
class Task
|
24
24
|
attr_reader :at, :expires_after, :frequency, :job_class, :job_class_name
|
@@ -56,7 +56,7 @@ module SimpleScheduler
|
|
56
56
|
@existing_jobs ||= SimpleScheduler::Task.scheduled_set.select do |job|
|
57
57
|
next unless job.display_class == "SimpleScheduler::FutureJob"
|
58
58
|
task_params = job.display_args[0]
|
59
|
-
task_params[
|
59
|
+
task_params["class"] == job_class_name && task_params["name"] == name
|
60
60
|
end.to_a
|
61
61
|
end
|
62
62
|
|
@@ -83,9 +83,9 @@ module SimpleScheduler
|
|
83
83
|
def future_run_times
|
84
84
|
future_run_times = existing_run_times.dup
|
85
85
|
last_run_time = future_run_times.last || first_run_time - frequency
|
86
|
-
last_run_time = last_run_time.in_time_zone(
|
86
|
+
last_run_time = last_run_time.in_time_zone(time_zone)
|
87
87
|
|
88
|
-
while future_run_times.length < 2 || ((last_run_time - now) / 1.minute) <
|
88
|
+
while future_run_times.length < 2 || ((last_run_time - now) / 1.minute) < queue_ahead
|
89
89
|
last_run_time = frequency.from_now(last_run_time)
|
90
90
|
last_run_time = last_run_time.change(hour: first_run_hour, min: first_run_min) if at_match[2]
|
91
91
|
future_run_times << last_run_time
|