sidekiq-postpone 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +14 -7
- data/Appraisals +8 -8
- data/gemfiles/{sidekiq_4.1.0.gemfile → sidekiq_4.1.gemfile} +1 -1
- data/gemfiles/{sidekiq_4.1.1.gemfile → sidekiq_4.2.gemfile} +1 -1
- data/gemfiles/{sidekiq_4.1.2.gemfile → sidekiq_5.0.gemfile} +1 -1
- data/gemfiles/{sidekiq_4.1.3.gemfile → sidekiq_master.gemfile} +1 -1
- data/lib/sidekiq/postpone/version.rb +1 -1
- data/lib/sidekiq/postpone.rb +60 -15
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 84a89193bb8e0ab78b7b5150307f5e59a130d8f7cd9042621c35bac7a1648ab4
|
4
|
+
data.tar.gz: 2cfae440c4f663e51bbf7866defac44525a0a2b77bbf4baf7e1b39278b535609
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee5312224a86a288ad8a0615ddb5dea981606fcaa602fa65fa840c8143fb836e42e0d9d5ea6667060a63df8edd9937db32b2606e0b10887d057336dff26f4a01
|
7
|
+
data.tar.gz: 1e39d84d4da4d3fc0d2b637367a9e7752b990dec5014e555764cbc480c5b13a616e7992d97bc309ef3a469c414f9290444acb548ad4b2dc49c51e88d8ee1601f
|
data/.travis.yml
CHANGED
@@ -4,10 +4,10 @@ services:
|
|
4
4
|
- redis-server
|
5
5
|
rvm:
|
6
6
|
- 2.1
|
7
|
-
- 2.2
|
7
|
+
- 2.2.2
|
8
8
|
- 2.3.0
|
9
|
+
- 2.4
|
9
10
|
gemfile:
|
10
|
-
- Gemfile
|
11
11
|
- gemfiles/sidekiq_3.0.gemfile
|
12
12
|
- gemfiles/sidekiq_3.1.gemfile
|
13
13
|
- gemfiles/sidekiq_3.2.gemfile
|
@@ -15,12 +15,19 @@ gemfile:
|
|
15
15
|
- gemfiles/sidekiq_3.4.gemfile
|
16
16
|
- gemfiles/sidekiq_3.5.gemfile
|
17
17
|
- gemfiles/sidekiq_4.0.gemfile
|
18
|
-
- gemfiles/sidekiq_4.1.
|
19
|
-
- gemfiles/sidekiq_4.
|
20
|
-
- gemfiles/
|
21
|
-
- gemfiles/
|
18
|
+
- gemfiles/sidekiq_4.1.gemfile
|
19
|
+
- gemfiles/sidekiq_4.2.gemfile
|
20
|
+
- gemfiles/sidekiq_5.0.gemfile
|
21
|
+
- gemfiles/sidekiq_master.gemfile
|
22
|
+
matrix:
|
23
|
+
fast_finish: true
|
24
|
+
exclude:
|
25
|
+
- gemfile: gemfiles/sidekiq_5.0.gemfile
|
26
|
+
rvm: 2.1
|
27
|
+
- gemfile: gemfiles/sidekiq_master.gemfile
|
28
|
+
rvm: 2.1
|
22
29
|
|
23
|
-
before_install: gem install bundler -v 1.
|
30
|
+
before_install: gem install bundler -v 1.15
|
24
31
|
script:
|
25
32
|
- bundle exec rake spec
|
26
33
|
- bundle exec rake spec:sidekiq_testing_integration
|
data/Appraisals
CHANGED
@@ -26,18 +26,18 @@ appraise 'sidekiq-4.0' do
|
|
26
26
|
gem 'sidekiq', '~> 4.0.0'
|
27
27
|
end
|
28
28
|
|
29
|
-
appraise 'sidekiq-4.1
|
30
|
-
gem 'sidekiq', '4.1.0'
|
29
|
+
appraise 'sidekiq-4.1' do
|
30
|
+
gem 'sidekiq', '~> 4.1.0'
|
31
31
|
end
|
32
32
|
|
33
|
-
appraise 'sidekiq-4.
|
34
|
-
gem 'sidekiq', '4.
|
33
|
+
appraise 'sidekiq-4.2' do
|
34
|
+
gem 'sidekiq', '~> 4.2.0'
|
35
35
|
end
|
36
36
|
|
37
|
-
appraise 'sidekiq-
|
38
|
-
gem 'sidekiq', '
|
37
|
+
appraise 'sidekiq-5.0' do
|
38
|
+
gem 'sidekiq', '~> 5.0.0'
|
39
39
|
end
|
40
40
|
|
41
|
-
appraise 'sidekiq-
|
42
|
-
gem 'sidekiq', '
|
41
|
+
appraise 'sidekiq-master' do
|
42
|
+
gem 'sidekiq', github: 'mperham/sidekiq'
|
43
43
|
end
|
data/lib/sidekiq/postpone.rb
CHANGED
@@ -11,18 +11,26 @@ class Sidekiq::Postpone
|
|
11
11
|
setup_schedule
|
12
12
|
end
|
13
13
|
|
14
|
-
def wrap
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
def wrap(join_parent: true, flush: true)
|
15
|
+
enter!
|
16
|
+
begin
|
17
|
+
yield self
|
18
|
+
rescue
|
19
|
+
clear!
|
20
|
+
raise
|
21
|
+
end.tap do
|
22
|
+
if join_parent && (parent = Thread.current[:sidekiq_postpone_stack][-2])
|
23
|
+
join!(parent)
|
24
|
+
elsif flush
|
25
|
+
flush!
|
26
|
+
end
|
19
27
|
end
|
20
28
|
ensure
|
21
|
-
|
29
|
+
leave!
|
22
30
|
end
|
23
31
|
|
24
|
-
def self.wrap(&block)
|
25
|
-
new.wrap(&block)
|
32
|
+
def self.wrap(*client_args, **kwargs, &block)
|
33
|
+
new(*client_args).wrap(**kwargs, &block)
|
26
34
|
end
|
27
35
|
|
28
36
|
def push(payloads)
|
@@ -34,25 +42,62 @@ class Sidekiq::Postpone
|
|
34
42
|
end
|
35
43
|
end
|
36
44
|
|
37
|
-
|
45
|
+
def clear!
|
46
|
+
@queues.clear
|
47
|
+
@schedule.clear
|
48
|
+
end
|
49
|
+
|
50
|
+
def flush!
|
51
|
+
return if empty?
|
52
|
+
|
53
|
+
current_postpone = Thread.current[:sidekiq_postpone]
|
54
|
+
Thread.current[:sidekiq_postpone] = nil # activate real raw_push
|
38
55
|
|
39
|
-
def flush
|
40
56
|
client = Sidekiq::Client.new(*@client_args)
|
41
57
|
raw_push = client.method(:raw_push)
|
42
58
|
@queues.each_value(&raw_push)
|
43
59
|
raw_push.(@schedule) unless @schedule.empty?
|
60
|
+
ensure
|
61
|
+
Thread.current[:sidekiq_postpone] = current_postpone
|
44
62
|
end
|
45
63
|
|
46
|
-
def
|
47
|
-
if
|
48
|
-
|
64
|
+
def join!(other)
|
65
|
+
return if empty?
|
66
|
+
|
67
|
+
@queues.each do |name, payloads|
|
68
|
+
other.queues[name].concat(payloads)
|
49
69
|
end
|
70
|
+
other.schedule.concat(@schedule)
|
71
|
+
|
72
|
+
clear!
|
73
|
+
end
|
50
74
|
|
75
|
+
def empty?
|
76
|
+
@queues.empty? && @schedule.empty?
|
77
|
+
end
|
78
|
+
|
79
|
+
protected
|
80
|
+
|
81
|
+
attr_reader :queues, :schedule
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def enter!
|
86
|
+
if @entered
|
87
|
+
raise 'Sidekiq::Postpone#wrap is not re-enterable on the same instance'
|
88
|
+
else
|
89
|
+
@entered = true
|
90
|
+
end
|
91
|
+
Thread.current[:sidekiq_postpone_stack] ||= []
|
92
|
+
Thread.current[:sidekiq_postpone_stack].push(self)
|
51
93
|
Thread.current[:sidekiq_postpone] = self
|
52
94
|
end
|
53
95
|
|
54
|
-
def
|
55
|
-
Thread.current[:
|
96
|
+
def leave!
|
97
|
+
Thread.current[:sidekiq_postpone_stack].pop
|
98
|
+
head = Thread.current[:sidekiq_postpone_stack].last
|
99
|
+
Thread.current[:sidekiq_postpone] = head
|
100
|
+
@entered = false
|
56
101
|
end
|
57
102
|
|
58
103
|
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.2.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:
|
11
|
+
date: 2018-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|
@@ -122,10 +122,10 @@ files:
|
|
122
122
|
- gemfiles/sidekiq_3.4.gemfile
|
123
123
|
- gemfiles/sidekiq_3.5.gemfile
|
124
124
|
- gemfiles/sidekiq_4.0.gemfile
|
125
|
-
- gemfiles/sidekiq_4.1.
|
126
|
-
- gemfiles/sidekiq_4.
|
127
|
-
- gemfiles/
|
128
|
-
- gemfiles/
|
125
|
+
- gemfiles/sidekiq_4.1.gemfile
|
126
|
+
- gemfiles/sidekiq_4.2.gemfile
|
127
|
+
- gemfiles/sidekiq_5.0.gemfile
|
128
|
+
- gemfiles/sidekiq_master.gemfile
|
129
129
|
- lib/sidekiq/postpone.rb
|
130
130
|
- lib/sidekiq/postpone/core_ext.rb
|
131
131
|
- lib/sidekiq/postpone/version.rb
|
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
149
|
version: '0'
|
150
150
|
requirements: []
|
151
151
|
rubyforge_project:
|
152
|
-
rubygems_version: 2.
|
152
|
+
rubygems_version: 2.7.6
|
153
153
|
signing_key:
|
154
154
|
specification_version: 4
|
155
155
|
summary: Bulk-pushes jobs to Sidekiq when you need it to.
|