talentbox-delayed_job_sequel 4.2.0 → 4.2.1
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4302cd23662982c235f239ad688b7e625590bef5
|
4
|
+
data.tar.gz: 216726ccad71885a93664e0478d2f2719d0ae4f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f124eca09c6ed6276f61c89223cda8509fff8d39019b52b1faca646bd1469c4d649282e4de261f530c17f77e515dfbd37e1a48c70d425c30db2675d584f5490a
|
7
|
+
data.tar.gz: 24862b85887f74e7235ae1675f284ea69343840e2634204222c84eba8d9b4d82d677226485cc0eff388ee5b3ec53c8fd67c19689fd642015edf89a10d5caee26
|
@@ -13,21 +13,26 @@ module Delayed
|
|
13
13
|
set_default_run_at
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
(
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
16
|
+
dataset_module do
|
17
|
+
def ready_to_run(worker_name, max_run_time)
|
18
|
+
db_time_now = model.db_time_now
|
19
|
+
lock_upper_bound = db_time_now - max_run_time
|
20
|
+
filter do
|
21
|
+
(
|
22
|
+
(run_at <= db_time_now) &
|
23
|
+
::Sequel.expr(:locked_at => nil) |
|
24
|
+
(::Sequel.expr(:locked_at) < lock_upper_bound) |
|
25
|
+
{:locked_by => worker_name}
|
26
|
+
) & {:failed_at => nil}
|
27
|
+
end
|
26
28
|
end
|
27
|
-
end
|
28
29
|
|
29
|
-
|
30
|
-
|
30
|
+
def by_priority
|
31
|
+
order(
|
32
|
+
::Sequel.expr(:priority).asc,
|
33
|
+
::Sequel.expr(:run_at).asc
|
34
|
+
)
|
35
|
+
end
|
31
36
|
end
|
32
37
|
|
33
38
|
def self.before_fork
|
@@ -41,8 +46,8 @@ module Delayed
|
|
41
46
|
|
42
47
|
def self.reserve(worker, max_run_time = Worker.max_run_time)
|
43
48
|
ds = ready_to_run(worker.name, max_run_time)
|
44
|
-
ds = ds.filter("priority >= ?", Worker.min_priority) if Worker.min_priority
|
45
|
-
ds = ds.filter("priority <= ?", Worker.max_priority) if Worker.max_priority
|
49
|
+
ds = ds.filter(::Sequel.lit("priority >= ?", Worker.min_priority)) if Worker.min_priority
|
50
|
+
ds = ds.filter(::Sequel.lit("priority <= ?", Worker.max_priority)) if Worker.max_priority
|
46
51
|
ds = ds.filter(:queue => Worker.queues) if Worker.queues.any?
|
47
52
|
ds = ds.by_priority
|
48
53
|
ds = ds.for_update
|
@@ -101,7 +106,13 @@ module Delayed
|
|
101
106
|
|
102
107
|
def self.count(attrs={})
|
103
108
|
if attrs.respond_to?(:has_key?) && attrs.has_key?(:conditions)
|
104
|
-
|
109
|
+
conditions = case attrs[:conditions]
|
110
|
+
when Array
|
111
|
+
::Sequel.lit(*attrs[:conditions])
|
112
|
+
else
|
113
|
+
::Sequel.lit(attrs[:conditions])
|
114
|
+
end
|
115
|
+
ds = self.where conditions
|
105
116
|
if attrs.has_key?(:group)
|
106
117
|
column = attrs[:group]
|
107
118
|
group_and_count(column.to_sym).map do |record|
|
@@ -13,7 +13,7 @@ describe Delayed::Backend::Sequel::Job do
|
|
13
13
|
it_should_behave_like "a delayed_job backend"
|
14
14
|
|
15
15
|
it "does not allow more than 1 worker to grab the same job" do
|
16
|
-
expect
|
16
|
+
expect do
|
17
17
|
10.times do
|
18
18
|
described_class.create(payload_object: SimpleJob.new)
|
19
19
|
end
|
@@ -25,7 +25,7 @@ describe Delayed::Backend::Sequel::Job do
|
|
25
25
|
worker.work_off(4)
|
26
26
|
end
|
27
27
|
end.map(&:join)
|
28
|
-
|
28
|
+
end.not_to raise_error
|
29
29
|
|
30
30
|
expect(Delayed::Job.count).to be < 10
|
31
31
|
end
|
@@ -35,8 +35,12 @@ describe Delayed::Backend::Sequel::Job do
|
|
35
35
|
it "allow count with conditions" do
|
36
36
|
described_class.create(failed_at: Time.now)
|
37
37
|
expect do
|
38
|
-
|
39
|
-
|
38
|
+
expect(
|
39
|
+
Delayed::Job.count(:conditions => "failed_at is not NULL")
|
40
|
+
).to eq 1
|
41
|
+
expect(
|
42
|
+
Delayed::Job.count(:conditions => "locked_by is not NULL")
|
43
|
+
).to eq 0
|
40
44
|
end.to_not raise_error
|
41
45
|
end
|
42
46
|
|
@@ -44,8 +48,12 @@ describe Delayed::Backend::Sequel::Job do
|
|
44
48
|
described_class.create(queue: "slow", priority: 2)
|
45
49
|
described_class.create(queue: "important", priority: 1)
|
46
50
|
expect do
|
47
|
-
|
48
|
-
|
51
|
+
expect(
|
52
|
+
Delayed::Job.count(:group => "queue", :conditions => ['run_at < ? and failed_at is NULL', Time.now])
|
53
|
+
).to match_array [["slow", 1], ["important", 1]]
|
54
|
+
expect(
|
55
|
+
Delayed::Job.count(:group => "priority", :conditions => ['run_at < ? and failed_at is NULL', Time.now])
|
56
|
+
).to match_array [[1, 1], [2, 1]]
|
49
57
|
end.to_not raise_error
|
50
58
|
end
|
51
59
|
end
|
@@ -54,25 +62,31 @@ describe Delayed::Backend::Sequel::Job do
|
|
54
62
|
context "db_time_now" do
|
55
63
|
it "should return time in current time zone if set" do
|
56
64
|
Time.zone = "Eastern Time (US & Canada)"
|
57
|
-
|
65
|
+
expect(
|
66
|
+
%w(EST EDT)
|
67
|
+
).to include(Delayed::Job.db_time_now.zone)
|
58
68
|
end
|
59
69
|
|
60
70
|
it "should return UTC time if that is the Sequel.database_timezone default" do
|
61
71
|
Time.zone = nil
|
62
72
|
Sequel.database_timezone = :utc
|
63
|
-
|
73
|
+
expect(
|
74
|
+
Delayed::Backend::Sequel::Job.db_time_now.zone
|
75
|
+
).to eql "UTC"
|
64
76
|
end
|
65
77
|
|
66
78
|
it "should return local time if that is the AR default" do
|
67
79
|
Time.zone = "Central Time (US & Canada)"
|
68
80
|
Sequel.database_timezone = :local
|
69
|
-
|
81
|
+
expect(
|
82
|
+
%w(CST CDT)
|
83
|
+
).to include(Delayed::Backend::Sequel::Job.db_time_now.zone)
|
70
84
|
end
|
71
85
|
end
|
72
86
|
|
73
87
|
describe "before_fork" do
|
74
88
|
it "should call disconnect on the connection" do
|
75
|
-
Sequel::Model.db.
|
89
|
+
expect( Sequel::Model.db ).to receive(:disconnect)
|
76
90
|
Delayed::Backend::Sequel::Job.before_fork
|
77
91
|
end
|
78
92
|
end
|
@@ -81,10 +95,14 @@ describe Delayed::Backend::Sequel::Job do
|
|
81
95
|
it "should allow enqueue hook to modify job at DB level" do
|
82
96
|
later = described_class.db_time_now + 20.minutes
|
83
97
|
job = Delayed::Backend::Sequel::Job.enqueue :payload_object => EnqueueJobMod.new
|
84
|
-
|
98
|
+
expect(
|
99
|
+
Delayed::Backend::Sequel::Job[job.id].run_at
|
100
|
+
).to be_within(1).of(later)
|
85
101
|
end
|
86
102
|
end
|
103
|
+
end
|
87
104
|
|
105
|
+
describe Delayed::Backend::Sequel::Job, "override table name" do
|
88
106
|
it "allows to override the table name" do
|
89
107
|
::Sequel::Model.db.transaction :rollback => :always do
|
90
108
|
begin
|
@@ -105,11 +123,11 @@ describe Delayed::Backend::Sequel::Job do
|
|
105
123
|
end
|
106
124
|
change_table_name :another_delayed_jobs
|
107
125
|
|
108
|
-
Delayed::Job.table_name.
|
126
|
+
expect( Delayed::Job.table_name ).to eql :another_delayed_jobs
|
109
127
|
ensure
|
110
128
|
change_table_name nil
|
111
129
|
# Replace described_class with reloaded
|
112
|
-
self.class.metadata[:
|
130
|
+
self.class.metadata[:described_class] = ::Delayed::Backend::Sequel::Job
|
113
131
|
end
|
114
132
|
end
|
115
133
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: talentbox-delayed_job_sequel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.
|
4
|
+
version: 4.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Tron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
@@ -64,14 +64,14 @@ dependencies:
|
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
67
|
+
version: 3.6.0
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
74
|
+
version: 3.6.0
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: rake
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
127
|
version: '0'
|
128
128
|
requirements: []
|
129
129
|
rubyforge_project:
|
130
|
-
rubygems_version: 2.
|
130
|
+
rubygems_version: 2.5.1
|
131
131
|
signing_key:
|
132
132
|
specification_version: 4
|
133
133
|
summary: Sequel backend for DelayedJob
|