sidekiq-cron 1.11.0 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/sidekiq/cron/job.rb +12 -8
- data/lib/sidekiq/cron/schedule_loader.rb +11 -13
- data/lib/sidekiq/cron/version.rb +1 -1
- data/lib/sidekiq/options.rb +6 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aaa6af217265c4e60b29018b984b43a4316b2618e52ce874db670e41ecadf85b
|
4
|
+
data.tar.gz: f70a50a90508ceb32bad90b8b2b6a880fb460f308dfa81f7380152742bb939cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef95b33d15c1867a3dc6cc096080af6f2fab50c4460d8be24948bcd887c6c278dc3ca1a8c92db8d1ce386d24e0ceb95f53f6add336c3315fec04f808b7451475
|
7
|
+
data.tar.gz: e30e02e3bcc13f8604426d5d9e5f30e24c46a85bfd7679544975a3bdfcc0510631d363ef041f948c8a51e289a02a222fd27bba572cf57ac1697aabb917673a01
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
+
## 1.12.0
|
6
|
+
|
7
|
+
- Remove Sidekiq.server? check from schedule loader (https://github.com/sidekiq-cron/sidekiq-cron/pull/436)
|
8
|
+
- Parse arguments on `args=` method (https://github.com/sidekiq-cron/sidekiq-cron/pull/442)
|
9
|
+
- Only check out a Redis connection if necessary (https://github.com/sidekiq-cron/sidekiq-cron/pull/438)
|
10
|
+
|
5
11
|
## 1.11.0
|
6
12
|
|
7
13
|
- Differentiates b/w "schedule" vs "dynamic" jobs (https://github.com/sidekiq-cron/sidekiq-cron/pull/431)
|
data/lib/sidekiq/cron/job.rb
CHANGED
@@ -21,11 +21,12 @@ module Sidekiq
|
|
21
21
|
|
22
22
|
# Crucial part of whole enqueuing job.
|
23
23
|
def should_enque? time
|
24
|
+
return false unless status == "enabled"
|
25
|
+
return false unless not_past_scheduled_time?(time)
|
26
|
+
return false unless not_enqueued_after?(time)
|
27
|
+
|
24
28
|
enqueue = Sidekiq.redis do |conn|
|
25
|
-
|
26
|
-
not_past_scheduled_time?(time) &&
|
27
|
-
not_enqueued_after?(time) &&
|
28
|
-
conn.zadd(job_enqueued_key, formatted_enqueue_time(time), formatted_last_time(time))
|
29
|
+
conn.zadd(job_enqueued_key, formatted_enqueue_time(time), formatted_last_time(time))
|
29
30
|
end
|
30
31
|
enqueue == true || enqueue == 1
|
31
32
|
end
|
@@ -239,12 +240,11 @@ module Sidekiq
|
|
239
240
|
def self.find name
|
240
241
|
# If name is hash try to get name from it.
|
241
242
|
name = name[:name] || name['name'] if name.is_a?(Hash)
|
243
|
+
return unless exists? name
|
242
244
|
|
243
245
|
output = nil
|
244
246
|
Sidekiq.redis do |conn|
|
245
|
-
|
246
|
-
output = Job.new conn.hgetall( redis_key(name) )
|
247
|
-
end
|
247
|
+
output = Job.new conn.hgetall( redis_key(name) )
|
248
248
|
end
|
249
249
|
output if output && output.valid?
|
250
250
|
end
|
@@ -294,7 +294,7 @@ module Sidekiq
|
|
294
294
|
|
295
295
|
# Get right arguments for job.
|
296
296
|
@symbolize_args = args["symbolize_args"] == true || ("#{args["symbolize_args"]}" =~ (/^(true|t|yes|y|1)$/i)) == 0 || false
|
297
|
-
@args =
|
297
|
+
@args = parse_args(args["args"])
|
298
298
|
|
299
299
|
@date_as_argument = args["date_as_argument"] == true || ("#{args["date_as_argument"]}" =~ (/^(true|t|yes|y|1)$/i)) == 0 || false
|
300
300
|
|
@@ -566,6 +566,10 @@ module Sidekiq
|
|
566
566
|
"#{status == "enabled" ? 0 : 1}_#{name}".downcase
|
567
567
|
end
|
568
568
|
|
569
|
+
def args=(args)
|
570
|
+
@args = parse_args(args)
|
571
|
+
end
|
572
|
+
|
569
573
|
private
|
570
574
|
|
571
575
|
def parsed_cron
|
@@ -2,20 +2,18 @@ require 'sidekiq'
|
|
2
2
|
require 'sidekiq/cron/job'
|
3
3
|
require 'sidekiq/options'
|
4
4
|
|
5
|
-
|
6
|
-
Sidekiq
|
7
|
-
schedule_file = Sidekiq::Options[:cron_schedule_file] || 'config/schedule.yml'
|
5
|
+
Sidekiq.configure_server do |config|
|
6
|
+
schedule_file = Sidekiq::Options[:cron_schedule_file] || 'config/schedule.yml'
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
8
|
+
if File.exist?(schedule_file)
|
9
|
+
config.on(:startup) do
|
10
|
+
schedule = Sidekiq::Cron::Support.load_yaml(ERB.new(IO.read(schedule_file)).result)
|
11
|
+
if schedule.kind_of?(Hash)
|
12
|
+
Sidekiq::Cron::Job.load_from_hash!(schedule, source: "schedule")
|
13
|
+
elsif schedule.kind_of?(Array)
|
14
|
+
Sidekiq::Cron::Job.load_from_array!(schedule, source: "schedule")
|
15
|
+
else
|
16
|
+
raise "Not supported schedule format. Confirm your #{schedule_file}"
|
19
17
|
end
|
20
18
|
end
|
21
19
|
end
|
data/lib/sidekiq/cron/version.rb
CHANGED
data/lib/sidekiq/options.rb
CHANGED
@@ -3,11 +3,15 @@ require 'sidekiq'
|
|
3
3
|
module Sidekiq
|
4
4
|
module Options
|
5
5
|
def self.[](key)
|
6
|
-
|
6
|
+
self.config[key]
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.[]=(key, value)
|
10
|
-
|
10
|
+
self.config[key] = value
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.config
|
14
|
+
options_field ? Sidekiq.public_send(options_field) : Sidekiq
|
11
15
|
end
|
12
16
|
|
13
17
|
def self.options_field
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-cron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ondrej Bartas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fugit
|