sidekiq-scheduler 2.1.6 → 2.1.7

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: c985cef8663dd93691d7126e7f3d171a90468ed1
4
- data.tar.gz: 14a52c0d0893dec74583c469a7add3642b7bd4ec
3
+ metadata.gz: 9f9d5095b0da933e653ac5a47bc0a0a0057ad48b
4
+ data.tar.gz: 9daee302488e577371f041188e7d0f84d9833913
5
5
  SHA512:
6
- metadata.gz: 137fbd73b53008346c7ece03eea9fb64c14790e13b0b1f824dbcb48b929fce42353ed1fdb98921c331b63c11890a10469b637a8b1f7e841f21c518730f946272
7
- data.tar.gz: 7ce02d5cd4ad8936c3f6203204aacf9756654ec8f4427caa849661bb9cc4962b765cddbefb1cae9507e94e64dc5c29ecda7294b623fe78e88a2f7404bbed00fc
6
+ metadata.gz: d356b101fd6427b204c46317604e2791135810173480b8ddfe4edb6c991008c9369b260dc576a7500ef33b8475ddbde41dab8d0bf281ccece6925e7aa75259a6
7
+ data.tar.gz: c6023a20103f5fdf9744e82435b2a68a6c2ec0407225602623886ede7297883a73e0523a4f664de5125ddc32318384122e2cf568eab5c5f7f46d0f6073cfb20d
@@ -53,8 +53,6 @@ module SidekiqScheduler
53
53
  end
54
54
 
55
55
  def schedule
56
- reload_schedule! unless @schedule
57
-
58
56
  @schedule
59
57
  end
60
58
 
@@ -106,7 +104,7 @@ module SidekiqScheduler
106
104
  existing_config = get_schedule(name)
107
105
  unless existing_config && existing_config == config
108
106
  Sidekiq.redis { |r| r.hset(:schedules, name, JSON.generate(config)) }
109
- Sidekiq.redis { |r| r.sadd(:schedules_changed, name) }
107
+ Sidekiq.redis { |r| r.zadd(:schedules_changed, Time.now.to_f, name) }
110
108
  end
111
109
  config
112
110
  end
@@ -114,7 +112,7 @@ module SidekiqScheduler
114
112
  # remove a given schedule by name
115
113
  def remove_schedule(name)
116
114
  Sidekiq.redis { |r| r.hdel(:schedules, name) }
117
- Sidekiq.redis { |r| r.sadd(:schedules_changed, name) }
115
+ Sidekiq.redis { |r| r.zadd(:schedules_changed, Time.now.to_f, name) }
118
116
  end
119
117
 
120
118
  private
@@ -1,5 +1,5 @@
1
1
  module SidekiqScheduler
2
2
 
3
- VERSION = '2.1.6'
3
+ VERSION = '2.1.7'
4
4
 
5
5
  end
@@ -22,6 +22,8 @@ module SidekiqScheduler
22
22
  end
23
23
 
24
24
  app.get '/recurring-jobs/:name/toggle' do
25
+ Sidekiq.reload_schedule!
26
+
25
27
  Sidekiq::Scheduler.toggle_job_enabled(params[:name])
26
28
  redirect "#{root_path}recurring-jobs"
27
29
  end
@@ -54,6 +54,7 @@ module Sidekiq
54
54
  # Load schedule from redis for the first time if dynamic
55
55
  if dynamic
56
56
  Sidekiq.reload_schedule!
57
+ @current_changed_score = Time.now.to_f
57
58
  rufus_scheduler.every('5s') do
58
59
  update_schedule
59
60
  end
@@ -73,7 +74,7 @@ module Sidekiq
73
74
  end
74
75
  end
75
76
 
76
- Sidekiq.redis { |r| r.del(:schedules_changed) }
77
+ Sidekiq.redis { |r| r.del(:schedules_changed) unless r.type(:schedules_changed) == 'zset' }
77
78
 
78
79
  logger.info 'Schedules Loaded'
79
80
  else
@@ -207,10 +208,15 @@ module Sidekiq
207
208
  end
208
209
 
209
210
  def update_schedule
210
- if Sidekiq.redis { |r| r.scard(:schedules_changed) } > 0
211
+ last_changed_score, @current_changed_score = @current_changed_score, Time.now.to_f
212
+ schedule_changes = Sidekiq.redis do |r|
213
+ r.zrangebyscore :schedules_changed, last_changed_score, "(#{@current_changed_score}"
214
+ end
215
+
216
+ if schedule_changes.size > 0
211
217
  logger.info 'Updating schedule'
212
218
  Sidekiq.reload_schedule!
213
- while schedule_name = Sidekiq.redis { |r| r.spop(:schedules_changed) }
219
+ schedule_changes.each do |schedule_name|
214
220
  if Sidekiq.schedule.keys.include?(schedule_name)
215
221
  unschedule_job(schedule_name)
216
222
  load_schedule_job(schedule_name, Sidekiq.schedule[schedule_name])
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.1.6
4
+ version: 2.1.7
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: 2017-06-23 00:00:00.000000000 Z
12
+ date: 2017-06-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sidekiq