sidekiq-cron 1.9.1 → 1.10.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 +14 -0
- data/Gemfile +3 -0
- data/README.md +23 -9
- data/lib/sidekiq/cron/job.rb +70 -10
- data/lib/sidekiq/cron/launcher.rb +1 -1
- data/lib/sidekiq/cron/schedule_loader.rb +2 -2
- data/lib/sidekiq/cron/version.rb +1 -1
- data/sidekiq-cron.gemspec +4 -2
- data/test/models/person.rb +21 -0
- data/test/test_helper.rb +6 -0
- data/test/unit/job_test.rb +130 -2
- data/test/unit/schedule_loader_test.rb +2 -2
- metadata +35 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1413d9d3418c71f816ea65bb6656c3053535d181ce22fbbc82daa3dca223f524
|
4
|
+
data.tar.gz: aecf5bb82af028c08f458a93aa8d96d6cc7c58ffe5b7a0380c33ecd5f02e42ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b135afb05139d833320da0efd60f76d1a55771f2bf3adfcf5fdcbe6f9e5bdd9c23ca3339bc354ee7ee9a5fe77da93eb73e2043ef1b37c7d78e7df1da9365a482
|
7
|
+
data.tar.gz: a1cfe3438ebd8eaec2bce2eac18f7f42983bdc5ed93e8dbf5810cf6eb01942847582a2b50526dcb36854ab6385555f41983aaad9bd85a89699c745d4c5196bd6
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,20 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
+
## 1.10.1
|
6
|
+
|
7
|
+
- use `hset` instead of deprecated `hmset` (https://github.com/sidekiq-cron/sidekiq-cron/pull/410)
|
8
|
+
|
9
|
+
## 1.10.0
|
10
|
+
|
11
|
+
- Remove EOL Ruby 2.6 support (https://github.com/sidekiq-cron/sidekiq-cron/pull/399)
|
12
|
+
- Add a logo for the project! (https://github.com/sidekiq-cron/sidekiq-cron/pull/402)
|
13
|
+
- Added support for ActiveRecord serialize/deserialize using GlobalID (https://github.com/sidekiq-cron/sidekiq-cron/pull/395)
|
14
|
+
- Allow for keyword args (`embedded: true`) in Poller (https://github.com/sidekiq-cron/sidekiq-cron/pull/398)
|
15
|
+
- Make last_enqueue_time be always an instance of Time (https://github.com/sidekiq-cron/sidekiq-cron/pull/354)
|
16
|
+
- Fix argument error problem update from 1.6.0 to newer (https://github.com/sidekiq-cron/sidekiq-cron/pull/392)
|
17
|
+
- Clear old jobs while loading the jobs from schedule via the schedule loader (https://github.com/sidekiq-cron/sidekiq-cron/pull/405)
|
18
|
+
|
5
19
|
## 1.9.1
|
6
20
|
|
7
21
|
- Always enqueue via Active Job interface when defined in cron job config (https://github.com/sidekiq-cron/sidekiq-cron/pull/381)
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
|
1
|
+
![Sidekiq-Cron](logos/cover.png)
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/sidekiq-cron.svg)](https://badge.fury.io/rb/sidekiq-cron)
|
4
4
|
[![Build Status](https://github.com/sidekiq-cron/sidekiq-cron/workflows/CI/badge.svg?branch=master)](https://github.com/sidekiq-cron/sidekiq-cron/actions)
|
5
|
-
[![
|
5
|
+
[![codecov](https://codecov.io/gh/sidekiq-cron/sidekiq-cron/branch/master/graph/badge.svg?token=VK9IVLIaY8)](https://codecov.io/gh/sidekiq-cron/sidekiq-cron)
|
6
6
|
|
7
7
|
> A scheduling add-on for [Sidekiq](https://sidekiq.org/)
|
8
8
|
|
@@ -26,12 +26,6 @@ Before upgrading to a new version, please read our [Changelog](CHANGELOG.md).
|
|
26
26
|
|
27
27
|
## Installation
|
28
28
|
|
29
|
-
### Requirements
|
30
|
-
|
31
|
-
- Redis 2.8 or greater is required (Redis 3.0.3 or greater is recommended for large scale use)
|
32
|
-
- Sidekiq 4.2 or greater is required (for Sidekiq < 4 use version sidekiq-cron 0.3.1)
|
33
|
-
- Sidekiq 6.5 requires Sidekiq-Cron 1.5+
|
34
|
-
|
35
29
|
Install the gem:
|
36
30
|
|
37
31
|
```
|
@@ -171,6 +165,26 @@ unless job.save
|
|
171
165
|
end
|
172
166
|
```
|
173
167
|
|
168
|
+
Use ActiveRecord models as arguments
|
169
|
+
|
170
|
+
```rb
|
171
|
+
class Person < ApplicationRecord
|
172
|
+
end
|
173
|
+
|
174
|
+
class HardWorker < ActiveJob::Base
|
175
|
+
queue_as :default
|
176
|
+
|
177
|
+
def perform(person)
|
178
|
+
puts "person: #{person}"
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
|
183
|
+
person = Person.create(id: 1)
|
184
|
+
Sidekiq::Cron::Job.create(name: 'Hard worker - every 5min', cron: '*/5 * * * *', class: 'HardWorker', args: person)
|
185
|
+
# => true
|
186
|
+
```
|
187
|
+
|
174
188
|
Load more jobs from hash:
|
175
189
|
|
176
190
|
```ruby
|
@@ -316,7 +330,7 @@ add `require 'sidekiq/cron/web'` after `require 'sidekiq/web'`.
|
|
316
330
|
|
317
331
|
With this, you will get:
|
318
332
|
|
319
|
-
![Web UI](
|
333
|
+
![Web UI](docs/images/web-cron-ui.jpeg)
|
320
334
|
|
321
335
|
## Under the hood
|
322
336
|
|
data/lib/sidekiq/cron/job.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'fugit'
|
2
|
+
require 'globalid'
|
2
3
|
require 'sidekiq'
|
3
4
|
require 'sidekiq/cron/support'
|
4
5
|
require 'sidekiq/options'
|
@@ -15,6 +16,9 @@ module Sidekiq
|
|
15
16
|
# Use the exists? method if we're on a newer version of Redis.
|
16
17
|
REDIS_EXISTS_METHOD = Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new("7.0.0") || Gem.loaded_specs['redis'].version < Gem::Version.new('4.2') ? :exists : :exists?
|
17
18
|
|
19
|
+
# Use serialize/deserialize key of GlobalID.
|
20
|
+
GLOBALID_KEY = "_sc_globalid"
|
21
|
+
|
18
22
|
# Crucial part of whole enqueuing job.
|
19
23
|
def should_enque? time
|
20
24
|
enqueue = Sidekiq.redis do |conn|
|
@@ -45,7 +49,7 @@ module Sidekiq
|
|
45
49
|
|
46
50
|
# Enqueue cron job to queue.
|
47
51
|
def enque! time = Time.now.utc
|
48
|
-
@last_enqueue_time = time
|
52
|
+
@last_enqueue_time = time
|
49
53
|
|
50
54
|
klass_const =
|
51
55
|
begin
|
@@ -85,7 +89,8 @@ module Sidekiq
|
|
85
89
|
end
|
86
90
|
|
87
91
|
def enqueue_args
|
88
|
-
date_as_argument? ? @args + [Time.now.to_f] : @args
|
92
|
+
args = date_as_argument? ? @args + [Time.now.to_f] : @args
|
93
|
+
deserialize_argument(args)
|
89
94
|
end
|
90
95
|
|
91
96
|
def enqueue_active_job(klass_const)
|
@@ -398,21 +403,26 @@ module Sidekiq
|
|
398
403
|
|
399
404
|
# Export job data to hash.
|
400
405
|
def to_hash
|
401
|
-
{
|
406
|
+
hash = {
|
402
407
|
name: @name,
|
403
408
|
klass: @klass.to_s,
|
404
409
|
cron: @cron,
|
405
410
|
description: @description,
|
406
411
|
args: @args.is_a?(String) ? @args : Sidekiq.dump_json(@args || []),
|
407
|
-
date_as_argument: date_as_argument? ? "1" : "0",
|
408
412
|
message: @message.is_a?(String) ? @message : Sidekiq.dump_json(@message || {}),
|
409
413
|
status: @status,
|
410
414
|
active_job: @active_job ? "1" : "0",
|
411
415
|
queue_name_prefix: @active_job_queue_name_prefix,
|
412
416
|
queue_name_delimiter: @active_job_queue_name_delimiter,
|
413
|
-
last_enqueue_time:
|
417
|
+
last_enqueue_time: serialized_last_enqueue_time,
|
414
418
|
symbolize_args: symbolize_args? ? "1" : "0",
|
415
419
|
}
|
420
|
+
|
421
|
+
if date_as_argument?
|
422
|
+
hash.merge!(date_as_argument: "1")
|
423
|
+
end
|
424
|
+
|
425
|
+
hash
|
416
426
|
end
|
417
427
|
|
418
428
|
def errors
|
@@ -459,7 +469,7 @@ module Sidekiq
|
|
459
469
|
conn.sadd self.class.jobs_key, [redis_key]
|
460
470
|
|
461
471
|
# Add informations for this job!
|
462
|
-
conn.
|
472
|
+
conn.hset redis_key, to_hash.transform_values! { |v| v || "" }
|
463
473
|
|
464
474
|
# Add information about last time! - don't enque right after scheduler poller starts!
|
465
475
|
time = Time.now.utc
|
@@ -472,7 +482,7 @@ module Sidekiq
|
|
472
482
|
def save_last_enqueue_time
|
473
483
|
Sidekiq.redis do |conn|
|
474
484
|
# Update last enqueue time.
|
475
|
-
conn.hset redis_key, 'last_enqueue_time',
|
485
|
+
conn.hset redis_key, 'last_enqueue_time', serialized_last_enqueue_time
|
476
486
|
end
|
477
487
|
end
|
478
488
|
|
@@ -569,6 +579,8 @@ module Sidekiq
|
|
569
579
|
# try to load JSON, then failover to string array.
|
570
580
|
def parse_args(args)
|
571
581
|
case args
|
582
|
+
when GlobalID::Identification
|
583
|
+
[convert_to_global_id_hash(args)]
|
572
584
|
when String
|
573
585
|
begin
|
574
586
|
parsed_args = Sidekiq.load_json(args)
|
@@ -577,8 +589,10 @@ module Sidekiq
|
|
577
589
|
[*args]
|
578
590
|
end
|
579
591
|
when Hash
|
592
|
+
args = serialize_argument(args)
|
580
593
|
symbolize_args? ? [symbolize_args(args)] : [args]
|
581
594
|
when Array
|
595
|
+
args = serialize_argument(args)
|
582
596
|
symbolize_args? ? symbolize_args(args) : args
|
583
597
|
else
|
584
598
|
[*args]
|
@@ -649,9 +663,55 @@ module Sidekiq
|
|
649
663
|
self.class.jid_history_key @name
|
650
664
|
end
|
651
665
|
|
652
|
-
|
653
|
-
|
654
|
-
|
666
|
+
def serialized_last_enqueue_time
|
667
|
+
@last_enqueue_time&.strftime(LAST_ENQUEUE_TIME_FORMAT)
|
668
|
+
end
|
669
|
+
|
670
|
+
def convert_to_global_id_hash(argument)
|
671
|
+
{ GLOBALID_KEY => argument.to_global_id.to_s }
|
672
|
+
rescue URI::GID::MissingModelIdError
|
673
|
+
raise "Unable to serialize #{argument.class} " \
|
674
|
+
"without an id. (Maybe you forgot to call save?)"
|
675
|
+
end
|
676
|
+
|
677
|
+
def deserialize_argument(argument)
|
678
|
+
case argument
|
679
|
+
when String
|
680
|
+
argument
|
681
|
+
when Array
|
682
|
+
argument.map { |arg| deserialize_argument(arg) }
|
683
|
+
when Hash
|
684
|
+
if serialized_global_id?(argument)
|
685
|
+
deserialize_global_id argument
|
686
|
+
else
|
687
|
+
argument.transform_values { |v| deserialize_argument(v) }
|
688
|
+
end
|
689
|
+
else
|
690
|
+
argument
|
691
|
+
end
|
692
|
+
end
|
693
|
+
|
694
|
+
def serialized_global_id?(hash)
|
695
|
+
hash.size == 1 && hash.include?(GLOBALID_KEY)
|
696
|
+
end
|
697
|
+
|
698
|
+
def deserialize_global_id(hash)
|
699
|
+
GlobalID::Locator.locate hash[GLOBALID_KEY]
|
700
|
+
end
|
701
|
+
|
702
|
+
def serialize_argument(argument)
|
703
|
+
case argument
|
704
|
+
when GlobalID::Identification
|
705
|
+
convert_to_global_id_hash(argument)
|
706
|
+
when Array
|
707
|
+
argument.map { |arg| serialize_argument(arg) }
|
708
|
+
when Hash
|
709
|
+
argument.each_with_object({}) do |(key, value), hash|
|
710
|
+
hash[key] = serialize_argument(value)
|
711
|
+
end
|
712
|
+
else
|
713
|
+
argument
|
714
|
+
end
|
655
715
|
end
|
656
716
|
end
|
657
717
|
end
|
@@ -14,7 +14,7 @@ module Sidekiq
|
|
14
14
|
attr_reader :cron_poller
|
15
15
|
|
16
16
|
# Add cron poller and execute normal initialize of Sidekiq launcher.
|
17
|
-
def initialize(config)
|
17
|
+
def initialize(config, **kwargs)
|
18
18
|
config[:cron_poll_interval] = DEFAULT_POLL_INTERVAL if config[:cron_poll_interval].nil?
|
19
19
|
|
20
20
|
@cron_poller = Sidekiq::Cron::Poller.new(config) if config[:cron_poll_interval] > 0
|
@@ -10,9 +10,9 @@ if Sidekiq.server?
|
|
10
10
|
config.on(:startup) do
|
11
11
|
schedule = Sidekiq::Cron::Support.load_yaml(ERB.new(IO.read(schedule_file)).result)
|
12
12
|
if schedule.kind_of?(Hash)
|
13
|
-
Sidekiq::Cron::Job.load_from_hash schedule
|
13
|
+
Sidekiq::Cron::Job.load_from_hash! schedule
|
14
14
|
elsif schedule.kind_of?(Array)
|
15
|
-
Sidekiq::Cron::Job.load_from_array schedule
|
15
|
+
Sidekiq::Cron::Job.load_from_array! schedule
|
16
16
|
else
|
17
17
|
raise "Not supported schedule format. Confirm your #{schedule_file}"
|
18
18
|
end
|
data/lib/sidekiq/cron/version.rb
CHANGED
data/sidekiq-cron.gemspec
CHANGED
@@ -24,10 +24,11 @@ Gem::Specification.new do |s|
|
|
24
24
|
"sidekiq-cron.gemspec",
|
25
25
|
]
|
26
26
|
|
27
|
-
s.required_ruby_version = ">= 2.
|
27
|
+
s.required_ruby_version = ">= 2.7"
|
28
28
|
|
29
29
|
s.add_dependency("fugit", "~> 1.8")
|
30
|
-
s.add_dependency("sidekiq", ">=
|
30
|
+
s.add_dependency("sidekiq", ">= 6")
|
31
|
+
s.add_dependency("globalid", ">= 1.0.1")
|
31
32
|
|
32
33
|
s.add_development_dependency("minitest", "~> 5.15")
|
33
34
|
s.add_development_dependency("mocha", "~> 1.14")
|
@@ -35,4 +36,5 @@ Gem::Specification.new do |s|
|
|
35
36
|
s.add_development_dependency("rack-test", "~> 1.1")
|
36
37
|
s.add_development_dependency("rake", "~> 13.0")
|
37
38
|
s.add_development_dependency("simplecov", "~> 0.21")
|
39
|
+
s.add_development_dependency("simplecov-cobertura", "~> 2.1")
|
38
40
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Person
|
2
|
+
include GlobalID::Identification
|
3
|
+
|
4
|
+
attr_reader :id
|
5
|
+
|
6
|
+
def self.find(id)
|
7
|
+
new(id)
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(id)
|
11
|
+
@id = id
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_global_id(options = {})
|
15
|
+
super app: "app"
|
16
|
+
end
|
17
|
+
|
18
|
+
def ==(other_person)
|
19
|
+
other_person.is_a?(Person) && id.to_s == other_person.id.to_s
|
20
|
+
end
|
21
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -2,6 +2,12 @@ $TESTING = true
|
|
2
2
|
ENV['RACK_ENV'] = 'test'
|
3
3
|
|
4
4
|
require 'simplecov'
|
5
|
+
|
6
|
+
if ENV['CI']
|
7
|
+
require 'simplecov-cobertura'
|
8
|
+
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
|
9
|
+
end
|
10
|
+
|
5
11
|
SimpleCov.start do
|
6
12
|
add_filter "test/"
|
7
13
|
add_group 'Sidekiq-Cron', 'lib/'
|
data/test/unit/job_test.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require './test/test_helper'
|
2
|
+
require "./test/models/person"
|
2
3
|
|
3
4
|
describe "Cron Job" do
|
4
5
|
before do
|
@@ -338,6 +339,45 @@ describe "Cron Job" do
|
|
338
339
|
assert args[-1].between?(Time.now.to_f - 1, Time.now.to_f)
|
339
340
|
end
|
340
341
|
end
|
342
|
+
|
343
|
+
describe 'with GlobalID::Identification args' do
|
344
|
+
before do
|
345
|
+
@args.merge!(args: Person.new(1))
|
346
|
+
@job = Sidekiq::Cron::Job.new(@args)
|
347
|
+
end
|
348
|
+
|
349
|
+
let(:args) { @job.sidekiq_worker_message['args'] }
|
350
|
+
|
351
|
+
it 'should add timestamp to args' do
|
352
|
+
assert_equal args[0], Person.new(1)
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
describe 'with GlobalID::Identification args in Array' do
|
357
|
+
before do
|
358
|
+
@args.merge!(args: [Person.new(1)])
|
359
|
+
@job = Sidekiq::Cron::Job.new(@args)
|
360
|
+
end
|
361
|
+
|
362
|
+
let(:args) { @job.sidekiq_worker_message['args'] }
|
363
|
+
|
364
|
+
it 'should add timestamp to args' do
|
365
|
+
assert_equal args[0], Person.new(1)
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
describe 'with GlobalID::Identification args in Hash' do
|
370
|
+
before do
|
371
|
+
@args.merge!(args: {person: Person.new(1)})
|
372
|
+
@job = Sidekiq::Cron::Job.new(@args)
|
373
|
+
end
|
374
|
+
|
375
|
+
let(:args) { @job.sidekiq_worker_message['args'] }
|
376
|
+
|
377
|
+
it 'should add timestamp to args' do
|
378
|
+
assert_equal args[0], {person: Person.new(1)}
|
379
|
+
end
|
380
|
+
end
|
341
381
|
end
|
342
382
|
|
343
383
|
describe '#sidekiq_worker_message settings overwrite queue name' do
|
@@ -777,6 +817,58 @@ describe "Cron Job" do
|
|
777
817
|
end
|
778
818
|
end
|
779
819
|
|
820
|
+
# @note sidekiq-cron 1.6.0 cannot process options correctly if any date_as_argument evaluates to true.
|
821
|
+
# This has been tested to resolve issues in environments where multiple sidekiq-cron versions are running when updating from 1.6.0
|
822
|
+
# See https://github.com/sidekiq-cron/sidekiq-cron/issues/350#issuecomment-1409798837 for more information.
|
823
|
+
describe "compat with sidekiq cron 1.6.0" do
|
824
|
+
describe "#to_hash with date_as_argument false" do
|
825
|
+
before do
|
826
|
+
@args = {
|
827
|
+
name: "Test",
|
828
|
+
cron: "* * * * *",
|
829
|
+
klass: "CronTestClass",
|
830
|
+
date_as_argument: false,
|
831
|
+
}
|
832
|
+
@job = Sidekiq::Cron::Job.new(@args)
|
833
|
+
end
|
834
|
+
|
835
|
+
it "should not have date_as_argument property" do
|
836
|
+
assert !@job.to_hash.key?(:date_as_argument)
|
837
|
+
end
|
838
|
+
end
|
839
|
+
|
840
|
+
describe "#to_hash with no date_as_argument option" do
|
841
|
+
before do
|
842
|
+
@args = {
|
843
|
+
name: "Test",
|
844
|
+
cron: "* * * * *",
|
845
|
+
klass: "CronTestClass",
|
846
|
+
}
|
847
|
+
@job = Sidekiq::Cron::Job.new(@args)
|
848
|
+
end
|
849
|
+
|
850
|
+
it "should not have date_as_argument property" do
|
851
|
+
assert !@job.to_hash.key?(:date_as_argument)
|
852
|
+
end
|
853
|
+
end
|
854
|
+
|
855
|
+
describe "#to_hash with date_as_argument" do
|
856
|
+
before do
|
857
|
+
@args = {
|
858
|
+
name: "Test",
|
859
|
+
cron: "* * * * *",
|
860
|
+
klass: "CronTestClass",
|
861
|
+
date_as_argument: true,
|
862
|
+
}
|
863
|
+
@job = Sidekiq::Cron::Job.new(@args)
|
864
|
+
end
|
865
|
+
|
866
|
+
it "should have date_as_argument property with value '1'" do
|
867
|
+
assert_equal @job.to_hash[:date_as_argument], '1'
|
868
|
+
end
|
869
|
+
end
|
870
|
+
end
|
871
|
+
|
780
872
|
describe "save" do
|
781
873
|
before do
|
782
874
|
@args = {
|
@@ -918,6 +1010,42 @@ describe "Cron Job" do
|
|
918
1010
|
assert_equal job.name, "Test"
|
919
1011
|
end
|
920
1012
|
end
|
1013
|
+
|
1014
|
+
it "from GlobalID::Identification" do
|
1015
|
+
args = {
|
1016
|
+
name: "Test",
|
1017
|
+
cron: "* * * * *",
|
1018
|
+
klass: "CronTestClass",
|
1019
|
+
args: Person.new(1)
|
1020
|
+
}
|
1021
|
+
Sidekiq::Cron::Job.new(args).tap do |job|
|
1022
|
+
assert_equal job.args, [{"_sc_globalid"=>"gid://app/Person/1"}]
|
1023
|
+
end
|
1024
|
+
end
|
1025
|
+
|
1026
|
+
it "from GlobalID::Identification in Array" do
|
1027
|
+
args = {
|
1028
|
+
name: "Test",
|
1029
|
+
cron: "* * * * *",
|
1030
|
+
klass: "CronTestClass",
|
1031
|
+
args: [Person.new(1)]
|
1032
|
+
}
|
1033
|
+
Sidekiq::Cron::Job.new(args).tap do |job|
|
1034
|
+
assert_equal job.args, [{"_sc_globalid"=>"gid://app/Person/1"}]
|
1035
|
+
end
|
1036
|
+
end
|
1037
|
+
|
1038
|
+
it "from GlobalID::Identification in Hash" do
|
1039
|
+
args = {
|
1040
|
+
name: "Test",
|
1041
|
+
cron: "* * * * *",
|
1042
|
+
klass: "CronTestClass",
|
1043
|
+
args: {person: Person.new(1)}
|
1044
|
+
}
|
1045
|
+
Sidekiq::Cron::Job.new(args).tap do |job|
|
1046
|
+
assert_equal job.args, [{person: {"_sc_globalid"=>"gid://app/Person/1"}}]
|
1047
|
+
end
|
1048
|
+
end
|
921
1049
|
end
|
922
1050
|
|
923
1051
|
describe "create & find methods" do
|
@@ -1145,11 +1273,11 @@ describe "Cron Job" do
|
|
1145
1273
|
end
|
1146
1274
|
|
1147
1275
|
it "duplicate jobs are not loaded" do
|
1148
|
-
out = Sidekiq::Cron::Job.load_from_hash @jobs_hash
|
1276
|
+
out = Sidekiq::Cron::Job.load_from_hash! @jobs_hash
|
1149
1277
|
assert_equal out.size, 0, "should have no errors"
|
1150
1278
|
assert_equal Sidekiq::Cron::Job.all.size, 2, "Should have 2 jobs after load"
|
1151
1279
|
|
1152
|
-
out_2 = Sidekiq::Cron::Job.load_from_hash @jobs_hash
|
1280
|
+
out_2 = Sidekiq::Cron::Job.load_from_hash! @jobs_hash
|
1153
1281
|
assert_equal out_2.size, 0, "should have no errors"
|
1154
1282
|
assert_equal Sidekiq::Cron::Job.all.size, 2, "Should have 2 jobs after loading again"
|
1155
1283
|
end
|
@@ -12,7 +12,7 @@ describe 'ScheduleLoader' do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'calls Sidekiq::Cron::Job.load_from_hash' do
|
15
|
-
Sidekiq::Cron::Job.expects(:load_from_hash)
|
15
|
+
Sidekiq::Cron::Job.expects(:load_from_hash!)
|
16
16
|
Sidekiq::Options[:lifecycle_events][:startup].first.call
|
17
17
|
end
|
18
18
|
end
|
@@ -24,7 +24,7 @@ describe 'ScheduleLoader' do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'calls Sidekiq::Cron::Job.load_from_array' do
|
27
|
-
Sidekiq::Cron::Job.expects(:load_from_array)
|
27
|
+
Sidekiq::Cron::Job.expects(:load_from_array!)
|
28
28
|
Sidekiq::Options[:lifecycle_events][:startup].first.call
|
29
29
|
end
|
30
30
|
end
|
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.10.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:
|
11
|
+
date: 2023-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fugit
|
@@ -30,14 +30,28 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '6'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: globalid
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.0.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.0.1
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: minitest
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +136,20 @@ dependencies:
|
|
122
136
|
- - "~>"
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: '0.21'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: simplecov-cobertura
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '2.1'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '2.1'
|
125
153
|
description: Enables to set jobs to be run in specified time (using CRON notation
|
126
154
|
or natural language)
|
127
155
|
email: ondrej@bartas.cz
|
@@ -158,6 +186,7 @@ files:
|
|
158
186
|
- lib/sidekiq/options.rb
|
159
187
|
- sidekiq-cron.gemspec
|
160
188
|
- test/integration/performance_test.rb
|
189
|
+
- test/models/person.rb
|
161
190
|
- test/test_helper.rb
|
162
191
|
- test/unit/fixtures/schedule_array.yml
|
163
192
|
- test/unit/fixtures/schedule_erb.yml
|
@@ -180,14 +209,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
180
209
|
requirements:
|
181
210
|
- - ">="
|
182
211
|
- !ruby/object:Gem::Version
|
183
|
-
version: '2.
|
212
|
+
version: '2.7'
|
184
213
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
214
|
requirements:
|
186
215
|
- - ">="
|
187
216
|
- !ruby/object:Gem::Version
|
188
217
|
version: '0'
|
189
218
|
requirements: []
|
190
|
-
rubygems_version: 3.
|
219
|
+
rubygems_version: 3.4.6
|
191
220
|
signing_key:
|
192
221
|
specification_version: 4
|
193
222
|
summary: Scheduler/Cron for Sidekiq jobs
|