sidekiq-scheduler 2.0.19 → 2.0.20

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: cd4d7812270a42a1fba60eb58d6bb15e64cea545
4
- data.tar.gz: f19980d703c2914483df61357fc3edd7d5fb4887
3
+ metadata.gz: b0729c34d520add53c677fd20e22ee3a29ee1e29
4
+ data.tar.gz: b437226e4b3c9214cca3e595c4e891e45de5672c
5
5
  SHA512:
6
- metadata.gz: 628c7aa26722c33a2744b3239412a307a59d9de62ac5182144eec62098942b5c31b902d24c22089b5bc6c8f5da8141ede0fbc29c42cc72f3f00301d329f929ea
7
- data.tar.gz: dc1e2a7c303f10fee40dadb5fa7cdb3ad6b8c6e4c437c478ec1beb65c1f32bf2cb88955b7c7e1c625a5d4a628915d84b71795fe4318585904e4e5ca62fdbabea
6
+ metadata.gz: 389f35144c0135f392266d6fd68fc8144fe06599475cd956ad1c70e4fa3c29eb0fa8c7f0609373e55ba6e610f6f616366d15164e171785e92b2ea0dd25b52cff
7
+ data.tar.gz: 021b55299dff4d7b00a6a3cf1a34acf52d44ceaa92d79ad3ccf3321b11534c2acfcf646887a08caeda317029bb03fcbe47430a178504aaaa048ded7830483caf
data/README.md CHANGED
@@ -145,6 +145,16 @@ seconds past the minute).
145
145
  A big shout out to [rufus-scheduler](http://github.com/jmettraux/rufus-scheduler)
146
146
  for handling the heavy lifting of the actual scheduling engine.
147
147
 
148
+ NOTE: As schedules are persisted in Redis, an empty schedule will purge any schedule previously stored.
149
+ sidekiq-scheduler instances running with `dynamic` flag set to `true` and empty schedule configuration will not push any job.
150
+ Before version 2.0.8, instances matching those conditions read the previously stored schedule and push the jobs to sidekiq as usual.
151
+
152
+ With version >= `2.0.8` the purge of Redis schedules config can be prevented by setting
153
+ `enabled` flag to `false`:
154
+
155
+ ```yaml
156
+ :enabled: false
157
+ ```
148
158
  ### Enabling/Disabling jobs
149
159
 
150
160
  By default all the jobs are enabled. There is an option at job's configuration to change
@@ -18,10 +18,13 @@ Sidekiq.configure_server do |config|
18
18
  listened_queues_only = Sidekiq::Scheduler.listened_queues_only
19
19
  listened_queues_only = listened_queues_only.nil? ? scheduler[:listened_queues_only] : listened_queues_only
20
20
 
21
+ schedule = Sidekiq.schedule
22
+ schedule ||= config.options[:schedule] || {}
23
+
21
24
  scheduler_options = {
22
25
  dynamic: dynamic,
23
26
  enabled: enabled,
24
- schedule: config.options.fetch(:schedule, nil),
27
+ schedule: schedule,
25
28
  listened_queues_only: listened_queues_only
26
29
  }
27
30
 
@@ -54,7 +54,9 @@ module SidekiqScheduler
54
54
  # @param schedule_hash [Hash] with the redis schedule
55
55
  # @return [Array<JobPresenter>] an array with the instances of presenters
56
56
  def self.build_collection(schedule_hash)
57
- Hash(schedule_hash).map do |name, job_spec|
57
+ schedule_hash ||= {}
58
+
59
+ schedule_hash.map do |name, job_spec|
58
60
  new(name, job_spec)
59
61
  end
60
62
  end
@@ -18,7 +18,7 @@ module SidekiqScheduler
18
18
  Sidekiq::Scheduler.enabled = options[:enabled]
19
19
  Sidekiq::Scheduler.dynamic = options[:dynamic]
20
20
  Sidekiq::Scheduler.listened_queues_only = options[:listened_queues_only]
21
- Sidekiq.schedule = options[:schedule] || {}
21
+ Sidekiq.schedule = options[:schedule]
22
22
  end
23
23
 
24
24
  def stop
@@ -38,7 +38,7 @@ module SidekiqScheduler
38
38
  # param, otherwise params is passed in as the only parameter to perform.
39
39
  def schedule=(schedule_hash)
40
40
  schedule_hash = prepare_schedule(schedule_hash)
41
- to_remove = (get_all_schedules || {}).keys - schedule_hash.keys.map(&:to_s)
41
+ to_remove = get_all_schedules.keys - schedule_hash.keys.map(&:to_s)
42
42
 
43
43
  schedule_hash.each do |name, job_spec|
44
44
  set_schedule(name, job_spec)
@@ -52,7 +52,7 @@ module SidekiqScheduler
52
52
  end
53
53
 
54
54
  def schedule
55
- @schedule ||= {}
55
+ @schedule
56
56
  end
57
57
 
58
58
  # Reloads the schedule from Redis and return it.
@@ -77,10 +77,9 @@ module SidekiqScheduler
77
77
 
78
78
  # gets the schedule as it exists in redis
79
79
  def get_all_schedules
80
- schedules = nil
81
- if Sidekiq.redis { |r| r.exists(:schedules) }
82
- schedules = {}
80
+ schedules = {}
83
81
 
82
+ if Sidekiq.redis { |r| r.exists(:schedules) }
84
83
  Sidekiq.redis { |r| r.hgetall(:schedules) }.tap do |h|
85
84
  h.each do |name, config|
86
85
  schedules[name] = JSON(config)
@@ -1,5 +1,5 @@
1
1
  module SidekiqScheduler
2
2
 
3
- VERSION = '2.0.19'
3
+ VERSION = '2.0.20'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-scheduler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.19
4
+ version: 2.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Morton Jonuschat
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-10-14 00:00:00.000000000 Z
12
+ date: 2016-10-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hashie