From eb2029a30bd25e2fece7147f8419259125a92207 Mon Sep 17 00:00:00 2001 From: Mike Rogers Date: Wed, 1 Jul 2020 11:50:08 +0100 Subject: [PATCH 1/9] Fix: Redis#exists(key) Warning from redis 4.2.0 --- lib/sidekiq/cron/job.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sidekiq/cron/job.rb b/lib/sidekiq/cron/job.rb index 313f8db5..5e855cb0 100644 --- a/lib/sidekiq/cron/job.rb +++ b/lib/sidekiq/cron/job.rb @@ -461,7 +461,7 @@ def save #add information about last time! - don't enque right after scheduler poller starts! time = Time.now.utc - conn.zadd(job_enqueued_key, time.to_f.to_s, formated_last_time(time).to_s) unless conn.exists(job_enqueued_key) + conn.zadd(job_enqueued_key, time.to_f.to_s, formated_last_time(time).to_s) unless conn.exists?(job_enqueued_key) end logger.info { "Cron Jobs - add job with name: #{@name}" } end @@ -540,7 +540,7 @@ def formated_last_time now = Time.now.utc def self.exists? name out = false Sidekiq.redis do |conn| - out = conn.exists redis_key name + out = conn.exists? redis_key name end out end From 48f08625ce6ea4354cca3d00dc5afe0cda3ccc7f Mon Sep 17 00:00:00 2001 From: Mike Rogers Date: Sun, 8 Nov 2020 15:49:06 +0000 Subject: [PATCH 2/9] Increasing redis-namespace requirement --- sidekiq-cron.gemspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sidekiq-cron.gemspec b/sidekiq-cron.gemspec index 5962d75d..b0cb6733 100644 --- a/sidekiq-cron.gemspec +++ b/sidekiq-cron.gemspec @@ -68,7 +68,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency(%q.freeze, ["~> 1.1"]) s.add_development_dependency(%q.freeze, [">= 0"]) s.add_development_dependency(%q.freeze, [">= 0"]) - s.add_development_dependency(%q.freeze, [">= 1.5.2"]) + s.add_development_dependency(%q.freeze, [">= 1.8.0"]) s.add_development_dependency(%q.freeze, [">= 0"]) s.add_development_dependency(%q.freeze, [">= 0"]) s.add_development_dependency(%q.freeze, [">= 0"]) @@ -88,7 +88,7 @@ Gem::Specification.new do |s| s.add_dependency(%q.freeze, ["~> 1.1"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) - s.add_dependency(%q.freeze, [">= 1.5.2"]) + s.add_dependency(%q.freeze, [">= 1.8.0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) @@ -109,7 +109,7 @@ Gem::Specification.new do |s| s.add_dependency(%q.freeze, ["~> 1.1"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) - s.add_dependency(%q.freeze, [">= 1.5.2"]) + s.add_dependency(%q.freeze, [">= 1.8.0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) From 6d24cb0e98116009cb81b855b68176fe3cd20fb9 Mon Sep 17 00:00:00 2001 From: Mike Rogers Date: Wed, 11 Nov 2020 14:55:03 +0000 Subject: [PATCH 3/9] Adding redis dependency requirement --- sidekiq-cron.gemspec | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sidekiq-cron.gemspec b/sidekiq-cron.gemspec index b0cb6733..4907d93f 100644 --- a/sidekiq-cron.gemspec +++ b/sidekiq-cron.gemspec @@ -66,6 +66,7 @@ Gem::Specification.new do |s| if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then s.add_runtime_dependency(%q.freeze, [">= 4.2.1"]) s.add_runtime_dependency(%q.freeze, ["~> 1.1"]) + s.add_runtime_dependency(%q.freeze, [">= 4.2.0"]) s.add_development_dependency(%q.freeze, [">= 0"]) s.add_development_dependency(%q.freeze, [">= 0"]) s.add_development_dependency(%q.freeze, [">= 1.8.0"]) @@ -92,6 +93,7 @@ Gem::Specification.new do |s| s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) + s.add_dependency(%q.freeze, [">= 4.2.0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) @@ -113,6 +115,7 @@ Gem::Specification.new do |s| s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) + s.add_dependency(%q.freeze, [">= 4.2.0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) From fa0b577022185eee8fca3a3d4979775ee0592978 Mon Sep 17 00:00:00 2001 From: Mike Rogers Date: Thu, 10 Dec 2020 20:32:24 +0000 Subject: [PATCH 4/9] Adjusting requirements - it makes my local tests pass --- docker-compose.yml | 2 ++ sidekiq-cron.gemspec | 1 + 2 files changed, 3 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index a21b9d52..54d06d36 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,8 @@ services: - 8.8.4.4 redis: image: redis + ports: + - "6379:6379" tests: image: sidekiq-cron-test environment: *environment diff --git a/sidekiq-cron.gemspec b/sidekiq-cron.gemspec index 4907d93f..30e99cbc 100644 --- a/sidekiq-cron.gemspec +++ b/sidekiq-cron.gemspec @@ -89,6 +89,7 @@ Gem::Specification.new do |s| s.add_dependency(%q.freeze, ["~> 1.1"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) + s.add_dependency(%q.freeze, [">= 4.2.0"]) s.add_dependency(%q.freeze, [">= 1.8.0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) From a8af9750327248ab4e3a77a36bd9b93c98b97ab0 Mon Sep 17 00:00:00 2001 From: Mike Rogers Date: Sun, 3 Jan 2021 22:02:59 +0000 Subject: [PATCH 5/9] Update sidekiq-cron.gemspec --- sidekiq-cron.gemspec | 2 -- 1 file changed, 2 deletions(-) diff --git a/sidekiq-cron.gemspec b/sidekiq-cron.gemspec index 30e99cbc..e1575eb3 100644 --- a/sidekiq-cron.gemspec +++ b/sidekiq-cron.gemspec @@ -94,7 +94,6 @@ Gem::Specification.new do |s| s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) - s.add_dependency(%q.freeze, [">= 4.2.0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) @@ -130,4 +129,3 @@ Gem::Specification.new do |s| s.add_dependency(%q.freeze, [">= 0"]) end end - From 687520c4d837ad1051dc77851f5a42eae80d03ba Mon Sep 17 00:00:00 2001 From: Mike Rogers Date: Mon, 25 Jan 2021 22:38:05 +0000 Subject: [PATCH 6/9] Using public_send to change the method called against the Redis connection --- lib/sidekiq/cron/job.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/sidekiq/cron/job.rb b/lib/sidekiq/cron/job.rb index 5e855cb0..6716da82 100644 --- a/lib/sidekiq/cron/job.rb +++ b/lib/sidekiq/cron/job.rb @@ -14,6 +14,9 @@ class Job REMEMBER_THRESHOLD = 24 * 60 * 60 LAST_ENQUEUE_TIME_FORMAT = '%Y-%m-%d %H:%M:%S %z' + # Use the exists? method if we're on a newer version of redis. + REDIS_EXISTS_METHOD = Gem.loaded_specs['redis'].version < Gem::Version.new('4.2') ? :exists : :exists? + #crucial part of whole enquing job def should_enque? time enqueue = false @@ -461,7 +464,7 @@ def save #add information about last time! - don't enque right after scheduler poller starts! time = Time.now.utc - conn.zadd(job_enqueued_key, time.to_f.to_s, formated_last_time(time).to_s) unless conn.exists?(job_enqueued_key) + conn.zadd(job_enqueued_key, time.to_f.to_s, formated_last_time(time).to_s) unless conn.public_send(REDIS_EXISTS_METHOD, job_enqueued_key) end logger.info { "Cron Jobs - add job with name: #{@name}" } end @@ -540,7 +543,7 @@ def formated_last_time now = Time.now.utc def self.exists? name out = false Sidekiq.redis do |conn| - out = conn.exists? redis_key name + out = conn.public_send(REDIS_EXISTS_METHOD, redis_key(name)) end out end From b4678fda73b1e94798510053b7a9791e67ab641f Mon Sep 17 00:00:00 2001 From: Mike Rogers Date: Mon, 25 Jan 2021 22:49:59 +0000 Subject: [PATCH 7/9] Removing ports from docker-compose file, I want this PR to be small --- docker-compose.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 54d06d36..a21b9d52 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,8 +11,6 @@ services: - 8.8.4.4 redis: image: redis - ports: - - "6379:6379" tests: image: sidekiq-cron-test environment: *environment From 68007c001856c960d17dfe60bc57fa6de602e0fd Mon Sep 17 00:00:00 2001 From: Mike Rogers Date: Tue, 26 Jan 2021 10:53:25 +0000 Subject: [PATCH 8/9] Reverting sidekiq-cron.gemspec file changes --- sidekiq-cron.gemspec | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sidekiq-cron.gemspec b/sidekiq-cron.gemspec index e1575eb3..1b86240c 100644 --- a/sidekiq-cron.gemspec +++ b/sidekiq-cron.gemspec @@ -66,10 +66,9 @@ Gem::Specification.new do |s| if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then s.add_runtime_dependency(%q.freeze, [">= 4.2.1"]) s.add_runtime_dependency(%q.freeze, ["~> 1.1"]) - s.add_runtime_dependency(%q.freeze, [">= 4.2.0"]) s.add_development_dependency(%q.freeze, [">= 0"]) s.add_development_dependency(%q.freeze, [">= 0"]) - s.add_development_dependency(%q.freeze, [">= 1.8.0"]) + s.add_development_dependency(%q.freeze, [">= 1.5.2"]) s.add_development_dependency(%q.freeze, [">= 0"]) s.add_development_dependency(%q.freeze, [">= 0"]) s.add_development_dependency(%q.freeze, [">= 0"]) @@ -89,8 +88,7 @@ Gem::Specification.new do |s| s.add_dependency(%q.freeze, ["~> 1.1"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) - s.add_dependency(%q.freeze, [">= 4.2.0"]) - s.add_dependency(%q.freeze, [">= 1.8.0"]) + s.add_dependency(%q.freeze, [">= 1.5.2"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) @@ -111,11 +109,10 @@ Gem::Specification.new do |s| s.add_dependency(%q.freeze, ["~> 1.1"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) - s.add_dependency(%q.freeze, [">= 1.8.0"]) + s.add_dependency(%q.freeze, [">= 1.5.2"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) - s.add_dependency(%q.freeze, [">= 4.2.0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) From 9957edc965a9c12dbdc1d3d2dd08d12be61bc347 Mon Sep 17 00:00:00 2001 From: Mike Rogers Date: Tue, 26 Jan 2021 10:53:58 +0000 Subject: [PATCH 9/9] Previous file had empty whitespace --- sidekiq-cron.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/sidekiq-cron.gemspec b/sidekiq-cron.gemspec index 1b86240c..5962d75d 100644 --- a/sidekiq-cron.gemspec +++ b/sidekiq-cron.gemspec @@ -126,3 +126,4 @@ Gem::Specification.new do |s| s.add_dependency(%q.freeze, [">= 0"]) end end +