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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38f49b844ee1ade391bc47b8acd2e98b02cb9d05041cad364fca427c51d3f65d
4
- data.tar.gz: 6328039e5648a59057202fec118775e8e1ed7ffc2d5a38229c62e4c7af7ebfaf
3
+ metadata.gz: aaa6af217265c4e60b29018b984b43a4316b2618e52ce874db670e41ecadf85b
4
+ data.tar.gz: f70a50a90508ceb32bad90b8b2b6a880fb460f308dfa81f7380152742bb939cf
5
5
  SHA512:
6
- metadata.gz: 80d176888e61a86fabac69a160fc778965b7900b8971979158a7e192289874fea61c18072dd6a306f6a3b8e456e68ea74df57a6e9ede9cb5f64d721228757ce5
7
- data.tar.gz: 27febbff9109ca10a5bfc7b6e4414f903e9021ca598ef94992b1445dd383f60d8d48f86f3bd0af93d60b6593a4e2adda26308c8cae42aabdcca0803be64005b1
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)
@@ -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
- status == "enabled" &&
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
- if exists? name
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 = args["args"].nil? ? [] : parse_args( args["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
- if Sidekiq.server?
6
- Sidekiq.configure_server do |config|
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
- if File.exist?(schedule_file)
10
- config.on(:startup) do
11
- schedule = Sidekiq::Cron::Support.load_yaml(ERB.new(IO.read(schedule_file)).result)
12
- if schedule.kind_of?(Hash)
13
- Sidekiq::Cron::Job.load_from_hash!(schedule, source: "schedule")
14
- elsif schedule.kind_of?(Array)
15
- Sidekiq::Cron::Job.load_from_array!(schedule, source: "schedule")
16
- else
17
- raise "Not supported schedule format. Confirm your #{schedule_file}"
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sidekiq
4
4
  module Cron
5
- VERSION = "1.11.0"
5
+ VERSION = "1.12.0"
6
6
  end
7
7
  end
@@ -3,11 +3,15 @@ require 'sidekiq'
3
3
  module Sidekiq
4
4
  module Options
5
5
  def self.[](key)
6
- options_field ? Sidekiq.public_send(options_field)[key] : Sidekiq[key]
6
+ self.config[key]
7
7
  end
8
8
 
9
9
  def self.[]=(key, value)
10
- options_field ? Sidekiq.public_send(options_field)[key] = value : Sidekiq[key] = value
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.11.0
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-03 00:00:00.000000000 Z
11
+ date: 2023-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fugit