sidekiq-postpone 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -3
- data/Appraisals +4 -0
- data/gemfiles/sidekiq_5.1.gemfile +7 -0
- data/lib/sidekiq/postpone.rb +26 -8
- data/lib/sidekiq/postpone/core_ext.rb +3 -1
- data/lib/sidekiq/postpone/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 634e909de058d8e5c067a0007f7e83c20e764552677104e53fa80add81e9ad54
|
4
|
+
data.tar.gz: 8b906c5ce4efc944e6e388736310fb6c71ff304f72a19ac388367c43cb67b9fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bff94b3c27b98308a5bbe2d8771d626583ddb66f10a8df9524262931c3993a278d264539032a969b15f58b1c7314a9cf1e5d554a517e4cef8944a397e0b8ef82
|
7
|
+
data.tar.gz: 8e05448529a78055810c04d5d2bc750138114a0081a3634d46d255ad89b24abba56dc763c7ef583393d788e3701532d8045114a533b09b632b88f84efc16d307
|
data/.travis.yml
CHANGED
@@ -4,9 +4,10 @@ services:
|
|
4
4
|
- redis-server
|
5
5
|
rvm:
|
6
6
|
- 2.1
|
7
|
-
- 2.2
|
8
|
-
- 2.3
|
7
|
+
- 2.2
|
8
|
+
- 2.3
|
9
9
|
- 2.4
|
10
|
+
- 2.5
|
10
11
|
gemfile:
|
11
12
|
- gemfiles/sidekiq_3.0.gemfile
|
12
13
|
- gemfiles/sidekiq_3.1.gemfile
|
@@ -18,14 +19,16 @@ gemfile:
|
|
18
19
|
- gemfiles/sidekiq_4.1.gemfile
|
19
20
|
- gemfiles/sidekiq_4.2.gemfile
|
20
21
|
- gemfiles/sidekiq_5.0.gemfile
|
22
|
+
- gemfiles/sidekiq_5.1.gemfile
|
21
23
|
- gemfiles/sidekiq_master.gemfile
|
22
24
|
matrix:
|
23
25
|
fast_finish: true
|
24
26
|
exclude:
|
27
|
+
- gemfile: gemfiles/sidekiq_5.1.gemfile
|
28
|
+
rvm: 2.1
|
25
29
|
- gemfile: gemfiles/sidekiq_5.0.gemfile
|
26
30
|
rvm: 2.1
|
27
31
|
- gemfile: gemfiles/sidekiq_master.gemfile
|
28
|
-
rvm: 2.1
|
29
32
|
|
30
33
|
before_install: gem install bundler -v 1.15
|
31
34
|
script:
|
data/Appraisals
CHANGED
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, **options)
|
15
|
+
enter!(**options)
|
16
16
|
begin
|
17
17
|
yield self
|
18
18
|
rescue
|
@@ -22,7 +22,7 @@ class Sidekiq::Postpone
|
|
22
22
|
if join_parent && (parent = Thread.current[:sidekiq_postpone_stack][-2])
|
23
23
|
join!(parent)
|
24
24
|
elsif flush
|
25
|
-
|
25
|
+
@flush_on_leave = true
|
26
26
|
end
|
27
27
|
end
|
28
28
|
ensure
|
@@ -34,12 +34,18 @@ 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
|
37
42
|
if payloads.first['at']
|
38
43
|
@schedule.concat(payloads)
|
39
44
|
else
|
40
45
|
q = payloads.first['queue']
|
41
46
|
@queues[q].concat(payloads)
|
42
47
|
end
|
48
|
+
ignored
|
43
49
|
end
|
44
50
|
|
45
51
|
def clear!
|
@@ -48,15 +54,17 @@ class Sidekiq::Postpone
|
|
48
54
|
end
|
49
55
|
|
50
56
|
def flush!
|
57
|
+
current_postpone = Thread.current[:sidekiq_postpone]
|
51
58
|
return if empty?
|
52
59
|
|
53
|
-
current_postpone = Thread.current[:sidekiq_postpone]
|
54
60
|
Thread.current[:sidekiq_postpone] = nil # activate real raw_push
|
55
61
|
|
56
62
|
client = Sidekiq::Client.new(*@client_args)
|
57
|
-
|
58
|
-
@queues.each_value(
|
59
|
-
raw_push
|
63
|
+
|
64
|
+
@queues.each_value { |item| client.raw_push(item) }
|
65
|
+
client.raw_push(@schedule) unless @schedule.empty?
|
66
|
+
|
67
|
+
clear!
|
60
68
|
ensure
|
61
69
|
Thread.current[:sidekiq_postpone] = current_postpone
|
62
70
|
end
|
@@ -76,18 +84,23 @@ class Sidekiq::Postpone
|
|
76
84
|
@queues.empty? && @schedule.empty?
|
77
85
|
end
|
78
86
|
|
87
|
+
def jids
|
88
|
+
[*@queues.values.flatten(1), *@schedule].map! { |j| j['jid'] }
|
89
|
+
end
|
90
|
+
|
79
91
|
protected
|
80
92
|
|
81
93
|
attr_reader :queues, :schedule
|
82
94
|
|
83
95
|
private
|
84
96
|
|
85
|
-
def enter!
|
97
|
+
def enter!(ignore: nil)
|
86
98
|
if @entered
|
87
99
|
raise 'Sidekiq::Postpone#wrap is not re-enterable on the same instance'
|
88
100
|
else
|
89
101
|
@entered = true
|
90
102
|
end
|
103
|
+
@ignore = ignore
|
91
104
|
Thread.current[:sidekiq_postpone_stack] ||= []
|
92
105
|
Thread.current[:sidekiq_postpone_stack].push(self)
|
93
106
|
Thread.current[:sidekiq_postpone] = self
|
@@ -98,6 +111,11 @@ class Sidekiq::Postpone
|
|
98
111
|
head = Thread.current[:sidekiq_postpone_stack].last
|
99
112
|
Thread.current[:sidekiq_postpone] = head
|
100
113
|
@entered = false
|
114
|
+
@ignore = nil
|
115
|
+
if @flush_on_leave
|
116
|
+
@flush_on_leave = false
|
117
|
+
flush!
|
118
|
+
end
|
101
119
|
end
|
102
120
|
|
103
121
|
def setup_queues
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-postpone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Kochnev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- gemfiles/sidekiq_4.1.gemfile
|
126
126
|
- gemfiles/sidekiq_4.2.gemfile
|
127
127
|
- gemfiles/sidekiq_5.0.gemfile
|
128
|
+
- gemfiles/sidekiq_5.1.gemfile
|
128
129
|
- gemfiles/sidekiq_master.gemfile
|
129
130
|
- lib/sidekiq/postpone.rb
|
130
131
|
- lib/sidekiq/postpone/core_ext.rb
|