sidekiq-cron 1.9.0 → 1.9.1
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 +5 -25
- data/lib/sidekiq/cron/schedule_loader.rb +1 -1
- data/lib/sidekiq/cron/support.rb +8 -0
- data/lib/sidekiq/cron/version.rb +1 -1
- data/sidekiq-cron.gemspec +1 -1
- data/test/unit/fixtures/schedule_erb.yml +3 -1
- data/test/unit/job_test.rb +30 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d751ce0280b4d30f1f43a1e0ed973166c2f398d7ac976e6fea267e66e999bb8
|
4
|
+
data.tar.gz: 352b64238d89eb4eedb0e9c046f9d54f6f298c376804de1066cbdad3481c43af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee7843b8dd62b31954de3db17c4cef76229050d2c4590bde276c77d6ad2c96bbb523620631ad41574d4b976ace4da6425130b1aa5c4a20986c4d42fdcdde1ef4
|
7
|
+
data.tar.gz: 95e74c836bdae7eb10fe1fe540fdc91ecb730c3a73bc1dd7e578d9324cf448e32054e9ad1b487036119076e966b0df1011978aa34b9215a334d996759d4bb684
|
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.9.1
|
6
|
+
|
7
|
+
- Always enqueue via Active Job interface when defined in cron job config (https://github.com/sidekiq-cron/sidekiq-cron/pull/381)
|
8
|
+
- Fix schedule.yml YAML load errors on Ruby 3.1 (https://github.com/sidekiq-cron/sidekiq-cron/pull/386)
|
9
|
+
- Require Fugit v1.8 to refactor internals (https://github.com/sidekiq-cron/sidekiq-cron/pull/385)
|
10
|
+
|
5
11
|
## 1.9.0
|
6
12
|
|
7
13
|
- Sidekiq v7 support (https://github.com/sidekiq-cron/sidekiq-cron/pull/369)
|
data/lib/sidekiq/cron/job.rb
CHANGED
@@ -56,7 +56,7 @@ module Sidekiq
|
|
56
56
|
|
57
57
|
jid =
|
58
58
|
if klass_const
|
59
|
-
if
|
59
|
+
if is_active_job?(klass_const)
|
60
60
|
enqueue_active_job(klass_const).try :provider_job_id
|
61
61
|
else
|
62
62
|
enqueue_sidekiq_worker(klass_const)
|
@@ -74,8 +74,8 @@ module Sidekiq
|
|
74
74
|
Sidekiq.logger.debug { "enqueued #{@name}: #{@message}" }
|
75
75
|
end
|
76
76
|
|
77
|
-
def is_active_job?
|
78
|
-
@active_job || defined?(ActiveJob::Base) && Sidekiq::Cron::Support.constantize(@klass.to_s) < ActiveJob::Base
|
77
|
+
def is_active_job?(klass = nil)
|
78
|
+
@active_job || defined?(ActiveJob::Base) && (klass || Sidekiq::Cron::Support.constantize(@klass.to_s)) < ActiveJob::Base
|
79
79
|
rescue NameError
|
80
80
|
false
|
81
81
|
end
|
@@ -428,15 +428,7 @@ module Sidekiq
|
|
428
428
|
errors << "'cron' must be set"
|
429
429
|
else
|
430
430
|
begin
|
431
|
-
|
432
|
-
|
433
|
-
# Since `Fugit.do_parse` might yield a Fugit::Duration or an EtOrbi::EoTime
|
434
|
-
# https://github.com/floraison/fugit#fugitparses
|
435
|
-
if c.is_a?(Fugit::Cron)
|
436
|
-
@parsed_cron = c
|
437
|
-
else
|
438
|
-
errors << "'cron' -> #{@cron.inspect} -> not a cron but a #{c.class}"
|
439
|
-
end
|
431
|
+
@parsed_cron = Fugit.do_parse_cronish(@cron)
|
440
432
|
rescue => e
|
441
433
|
errors << "'cron' -> #{@cron.inspect} -> #{e.class}: #{e.message}"
|
442
434
|
end
|
@@ -565,19 +557,7 @@ module Sidekiq
|
|
565
557
|
private
|
566
558
|
|
567
559
|
def parsed_cron
|
568
|
-
@parsed_cron ||=
|
569
|
-
c = Fugit.parse(@cron)
|
570
|
-
|
571
|
-
# Since `Fugit.parse` might yield a Fugit::Duration or an EtOrbi::EoTime
|
572
|
-
# https://github.com/floraison/fugit#fugitparses
|
573
|
-
if c.is_a?(Fugit::Cron)
|
574
|
-
c
|
575
|
-
else
|
576
|
-
errors << "'cron' -> #{@cron.inspect} -> not a cron but a #{c.class}"
|
577
|
-
end
|
578
|
-
rescue => e
|
579
|
-
errors << "'cron' -> #{@cron.inspect} -> #{e.class}: #{e.message}"
|
580
|
-
end
|
560
|
+
@parsed_cron ||= Fugit.parse_cronish(@cron)
|
581
561
|
end
|
582
562
|
|
583
563
|
def not_enqueued_after?(time)
|
@@ -8,7 +8,7 @@ if Sidekiq.server?
|
|
8
8
|
|
9
9
|
if File.exist?(schedule_file)
|
10
10
|
config.on(:startup) do
|
11
|
-
schedule =
|
11
|
+
schedule = Sidekiq::Cron::Support.load_yaml(ERB.new(IO.read(schedule_file)).result)
|
12
12
|
if schedule.kind_of?(Hash)
|
13
13
|
Sidekiq::Cron::Job.load_from_hash schedule
|
14
14
|
elsif schedule.kind_of?(Array)
|
data/lib/sidekiq/cron/support.rb
CHANGED
data/lib/sidekiq/cron/version.rb
CHANGED
data/sidekiq-cron.gemspec
CHANGED
data/test/unit/job_test.rb
CHANGED
@@ -581,6 +581,36 @@ describe "Cron Job" do
|
|
581
581
|
@job.enque!
|
582
582
|
end
|
583
583
|
end
|
584
|
+
|
585
|
+
describe 'with active_job == true' do
|
586
|
+
before do
|
587
|
+
@args.merge!(active_job: true)
|
588
|
+
end
|
589
|
+
|
590
|
+
describe 'with active_job job class' do
|
591
|
+
before do
|
592
|
+
@job = Sidekiq::Cron::Job.new(@args.merge(klass: 'ActiveJobCronTestClass'))
|
593
|
+
end
|
594
|
+
|
595
|
+
it 'enques via active_job interface' do
|
596
|
+
@job.expects(:enqueue_active_job)
|
597
|
+
.returns(ActiveJobCronTestClass.new)
|
598
|
+
@job.enque!
|
599
|
+
end
|
600
|
+
end
|
601
|
+
|
602
|
+
describe 'with non sidekiq job class' do
|
603
|
+
before do
|
604
|
+
@job = Sidekiq::Cron::Job.new(@args.merge(klass: 'CronTestClass'))
|
605
|
+
end
|
606
|
+
|
607
|
+
it 'enques via active_job interface' do
|
608
|
+
@job.expects(:enqueue_active_job)
|
609
|
+
.returns(ActiveJobCronTestClass.new)
|
610
|
+
@job.enque!
|
611
|
+
end
|
612
|
+
end
|
613
|
+
end
|
584
614
|
end
|
585
615
|
|
586
616
|
describe 'active job with queue_name_prefix' do
|
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.9.
|
4
|
+
version: 1.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ondrej Bartas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fugit
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1'
|
19
|
+
version: '1.8'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1'
|
26
|
+
version: '1.8'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sidekiq
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|