sidekiq-postpone 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sidekiq/postpone.rb +8 -12
- data/lib/sidekiq/postpone/core_ext.rb +1 -3
- data/lib/sidekiq/postpone/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 397128457629c5407f0a9eeae069ad7345d91dc08d8233aabd2003a0c7669131
|
4
|
+
data.tar.gz: 220589b707e7d63b1a94c8221bce1242aa56471743963080f9703647c73f663b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d861f1d3d91792a1252877ae235854382f4c0321387d516ecba7bb31cd75c93b45cd7340c07df4c17145a35d56890b1115af6d8781fc9b8d1e03f0e50e67388
|
7
|
+
data.tar.gz: 181b4c712f1c0d3d93be653c75c1032a72b59fe9b6fe2fe237a6d748a53e45346a94ef995d4a1541986cc7a281effd230b817180f1a8cd1bc632ac5cadbb096d
|
data/lib/sidekiq/postpone.rb
CHANGED
@@ -11,8 +11,8 @@ class Sidekiq::Postpone
|
|
11
11
|
setup_schedule
|
12
12
|
end
|
13
13
|
|
14
|
-
def wrap(join_parent: true, flush: true
|
15
|
-
enter!
|
14
|
+
def wrap(join_parent: true, flush: true)
|
15
|
+
enter!
|
16
16
|
begin
|
17
17
|
yield self
|
18
18
|
rescue
|
@@ -34,18 +34,12 @@ class Sidekiq::Postpone
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def push(payloads)
|
37
|
-
if @ignore
|
38
|
-
payloads, ignored = payloads.partition(&@ignore)
|
39
|
-
ignored = nil if ignored.empty?
|
40
|
-
return ignored if payloads.empty?
|
41
|
-
end
|
42
37
|
if payloads.first['at']
|
43
38
|
@schedule.concat(payloads)
|
44
39
|
else
|
45
40
|
q = payloads.first['queue']
|
46
41
|
@queues[q].concat(payloads)
|
47
42
|
end
|
48
|
-
ignored
|
49
43
|
end
|
50
44
|
|
51
45
|
def clear!
|
@@ -84,8 +78,12 @@ class Sidekiq::Postpone
|
|
84
78
|
@queues.empty? && @schedule.empty?
|
85
79
|
end
|
86
80
|
|
81
|
+
def all_jobs
|
82
|
+
[*@queues.values.flatten(1), *@schedule]
|
83
|
+
end
|
84
|
+
|
87
85
|
def jids
|
88
|
-
|
86
|
+
all_jobs.map! { |j| j['jid'] }
|
89
87
|
end
|
90
88
|
|
91
89
|
protected
|
@@ -94,13 +92,12 @@ class Sidekiq::Postpone
|
|
94
92
|
|
95
93
|
private
|
96
94
|
|
97
|
-
def enter!
|
95
|
+
def enter!
|
98
96
|
if @entered
|
99
97
|
raise 'Sidekiq::Postpone#wrap is not re-enterable on the same instance'
|
100
98
|
else
|
101
99
|
@entered = true
|
102
100
|
end
|
103
|
-
@ignore = ignore
|
104
101
|
Thread.current[:sidekiq_postpone_stack] ||= []
|
105
102
|
Thread.current[:sidekiq_postpone_stack].push(self)
|
106
103
|
Thread.current[:sidekiq_postpone] = self
|
@@ -111,7 +108,6 @@ class Sidekiq::Postpone
|
|
111
108
|
head = Thread.current[:sidekiq_postpone_stack].last
|
112
109
|
Thread.current[:sidekiq_postpone] = head
|
113
110
|
@entered = false
|
114
|
-
@ignore = nil
|
115
111
|
if @flush_on_leave
|
116
112
|
@flush_on_leave = false
|
117
113
|
flush!
|