sidekiq-cron 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changes.md +6 -0
- data/README.md +3 -3
- data/VERSION +1 -1
- data/lib/sidekiq/cron/job.rb +14 -1
- data/sidekiq-cron.gemspec +3 -3
- data/test/unit/job_test.rb +24 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 873586d3842f9498012e042967394936f59ff000
|
4
|
+
data.tar.gz: 455f2a83bca498a0b0b6d37c4a9dd359170a6f28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6eba0a3a0270f83abb155ac4683d03aa06f30e8d801c0b242e627dc29cd04d646f1e7d91c5a45da9b1197e8dd968d09e88fa4df3161cc216e3d097e7a319c036
|
7
|
+
data.tar.gz: 7776ad92e891399343e16020e2fb7136e472614fdc7a9503910e48bffe5e1a442456cf1785bd885d1c808a24d77f8e28ea058bc6a299b51eb0f486f7b98d4f15
|
data/Changes.md
CHANGED
data/README.md
CHANGED
@@ -17,8 +17,8 @@ Works with ActiveJob (Rails 4.2+)
|
|
17
17
|
Requirements
|
18
18
|
-----------------
|
19
19
|
|
20
|
-
- Redis 2.
|
21
|
-
- Sidekiq 4 or
|
20
|
+
- Redis 2.8 or greater is required. (Redis 3.0.3 or greater is recommended for large scale use)
|
21
|
+
- Sidekiq 4 or greater is required (for Sidekiq < 4 use version sidekiq-cron 0.3.1)
|
22
22
|
|
23
23
|
Change Log
|
24
24
|
----------
|
@@ -32,7 +32,7 @@ Installation
|
|
32
32
|
|
33
33
|
or add to your `Gemfile`
|
34
34
|
|
35
|
-
gem "sidekiq-cron", "~> 0.
|
35
|
+
gem "sidekiq-cron", "~> 0.4.0"
|
36
36
|
|
37
37
|
|
38
38
|
Getting Started
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.1
|
data/lib/sidekiq/cron/job.rb
CHANGED
@@ -16,7 +16,10 @@ module Sidekiq
|
|
16
16
|
def should_enque? time
|
17
17
|
enqueue = false
|
18
18
|
enqueue = Sidekiq.redis do |conn|
|
19
|
-
status == "enabled" &&
|
19
|
+
status == "enabled" &&
|
20
|
+
not_past_scheduled_time?(time) &&
|
21
|
+
not_enqueued_after?(time) &&
|
22
|
+
conn.zadd(job_enqueued_key, formated_enqueue_time(time), formated_last_time(time))
|
20
23
|
end
|
21
24
|
enqueue
|
22
25
|
end
|
@@ -433,6 +436,10 @@ module Sidekiq
|
|
433
436
|
Rufus::Scheduler::CronLine.new(@cron).previous_time(now)
|
434
437
|
end
|
435
438
|
|
439
|
+
def formated_enqueue_time now = Time.now
|
440
|
+
last_time(now).getutc.to_f.to_s
|
441
|
+
end
|
442
|
+
|
436
443
|
def formated_last_time now = Time.now
|
437
444
|
last_time(now).getutc.iso8601
|
438
445
|
end
|
@@ -480,6 +487,12 @@ module Sidekiq
|
|
480
487
|
end
|
481
488
|
end
|
482
489
|
|
490
|
+
def not_past_scheduled_time?(current_time)
|
491
|
+
last_cron_time = Rufus::Scheduler::CronLine.new(@cron).previous_time(current_time)
|
492
|
+
return false if (current_time - last_cron_time) > 60
|
493
|
+
true
|
494
|
+
end
|
495
|
+
|
483
496
|
# Redis key for set of all cron jobs
|
484
497
|
def self.jobs_key
|
485
498
|
"cron_jobs"
|
data/sidekiq-cron.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: sidekiq-cron 0.4.
|
5
|
+
# stub: sidekiq-cron 0.4.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "sidekiq-cron"
|
9
|
-
s.version = "0.4.
|
9
|
+
s.version = "0.4.1"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Ondrej Bartas"]
|
14
|
-
s.date = "2015-
|
14
|
+
s.date = "2015-12-20"
|
15
15
|
s.description = "Enables to set jobs to be run in specified time (using CRON notation)"
|
16
16
|
s.email = "ondrej@bartas.cz"
|
17
17
|
s.extra_rdoc_files = [
|
data/test/unit/job_test.rb
CHANGED
@@ -132,6 +132,25 @@ describe "Cron Job" do
|
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
|
+
describe 'formatted time' do
|
136
|
+
before do
|
137
|
+
@args = {
|
138
|
+
name: "Test",
|
139
|
+
cron: "* * * * *"
|
140
|
+
}
|
141
|
+
@job = Sidekiq::Cron::Job.new(@args)
|
142
|
+
@time = Time.new(2015, 1, 2, 3, 4, 5, '+01:00')
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'returns formatted_last_time' do
|
146
|
+
assert_equal '2015-01-02T02:04:00Z', @job.formated_last_time(@time)
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'returns formated_enqueue_time' do
|
150
|
+
assert_equal '1420164240.0', @job.formated_enqueue_time(@time)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
135
154
|
describe "new with different class inputs" do
|
136
155
|
it "be initialized by 'klass' and Class" do
|
137
156
|
job = Sidekiq::Cron::Job.new('klass' => CronTestClass)
|
@@ -794,6 +813,11 @@ describe "Cron Job" do
|
|
794
813
|
refute Sidekiq::Cron::Job.new(@args).should_enque? @time + 235
|
795
814
|
end
|
796
815
|
|
816
|
+
it "should not enqueue jobs that are past" do
|
817
|
+
assert Sidekiq::Cron::Job.new(@args.merge(cron: "*/1 * * * *")).should_enque? @time
|
818
|
+
refute Sidekiq::Cron::Job.new(@args.merge(cron: "0 1,13 * * *")).should_enque? @time
|
819
|
+
end
|
820
|
+
|
797
821
|
it "remove old enque times + should be enqeued" do
|
798
822
|
job = Sidekiq::Cron::Job.new(@args)
|
799
823
|
assert_nil job.last_enqueue_time
|
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: 0.4.
|
4
|
+
version: 0.4.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: 2015-
|
11
|
+
date: 2015-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|