sidekiq-ultimate 0.0.1.alpha.14 → 0.0.1.alpha.19
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f588d8dd927a0eaba4910ffbded5a8a24f69b6e8aae7c45b4bb28092373e6825
|
4
|
+
data.tar.gz: e2701097c8fbc5c99054bdb36a3bb4ae1089ee91abd1da74dfab4cab94f12ef7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5a37773ca7013b24a5e7abb15aab91f7667f157b7e5d4bf43085c8268546a50d51319d351fad4db478428ee437d4acd43f762b33212a96d0d5d3bea57ad7d77
|
7
|
+
data.tar.gz: 7ceeb9436521f998f9f34e642f22aee1e8762e60c6ae9f5689b82902b95a27d6c1578aee89bd984ca81dca91fcfb4ef227eae170c9bfb1e854a1f17cd9ba08f6
|
@@ -34,10 +34,15 @@ module Sidekiq
|
|
34
34
|
|
35
35
|
# Create a new ExpirableSet instance.
|
36
36
|
def initialize
|
37
|
-
@set =
|
37
|
+
@set = Hash.new(0.0)
|
38
38
|
@mon = Monitor.new
|
39
39
|
end
|
40
40
|
|
41
|
+
# Allow implicit coercion to Array:
|
42
|
+
#
|
43
|
+
# ["x"] + ExpirableSet.new.add("y", :ttl => 10) # => ["x", "y"]
|
44
|
+
#
|
45
|
+
# @return [Array]
|
41
46
|
alias to_ary to_a
|
42
47
|
|
43
48
|
# Adds given element into the set.
|
@@ -50,9 +55,7 @@ module Sidekiq
|
|
50
55
|
expires_at = Concurrent.monotonic_time + ttl
|
51
56
|
|
52
57
|
# do not allow decrease element's expiry
|
53
|
-
|
54
|
-
|
55
|
-
@set[element] = expires_at
|
58
|
+
@set[element] = expires_at if @set[element] < expires_at
|
56
59
|
end
|
57
60
|
|
58
61
|
self
|
@@ -69,7 +72,7 @@ module Sidekiq
|
|
69
72
|
|
70
73
|
@mon.synchronize do
|
71
74
|
horizon = Concurrent.monotonic_time
|
72
|
-
@set.each { |k, v|
|
75
|
+
@set.each { |k, v| yield(k) if horizon <= v }
|
73
76
|
end
|
74
77
|
|
75
78
|
self
|
@@ -11,12 +11,14 @@ module Sidekiq
|
|
11
11
|
module Ultimate
|
12
12
|
# Throttled reliable fetcher implementing reliable queue pattern.
|
13
13
|
class Fetch
|
14
|
-
#
|
14
|
+
# Delay between fetch retries in case of no job received.
|
15
15
|
TIMEOUT = 2
|
16
16
|
|
17
|
-
#
|
18
|
-
|
19
|
-
|
17
|
+
# Delay between queue poll attempts if last poll returned no jobs for it.
|
18
|
+
QUEUE_TIMEOUT = 5
|
19
|
+
|
20
|
+
# Delay between queue poll attempts if it's last job was throttled.
|
21
|
+
THROTTLE_TIMEOUT = 15
|
20
22
|
|
21
23
|
def initialize(options)
|
22
24
|
@exhausted = ExpirableSet.new
|
@@ -25,17 +27,25 @@ module Sidekiq
|
|
25
27
|
@queues = options[:queues].map { |name| QueueName.new(name) }
|
26
28
|
|
27
29
|
@queues.uniq! if @strict
|
30
|
+
|
31
|
+
@paused_queues = []
|
32
|
+
@paused_queues_expires_at = 0
|
28
33
|
end
|
29
34
|
|
35
|
+
# @return [UnitOfWork] if work can be processed
|
30
36
|
def retrieve_work
|
31
37
|
work = retrieve
|
32
38
|
|
33
|
-
|
34
|
-
|
39
|
+
if work&.throttled?
|
40
|
+
work.requeue_throttled
|
35
41
|
|
36
|
-
|
42
|
+
queue = QueueName.new(work.queue_name)
|
43
|
+
@exhausted.add(queue, :ttl => THROTTLE_TIMEOUT)
|
44
|
+
|
45
|
+
return nil
|
46
|
+
end
|
37
47
|
|
38
|
-
|
48
|
+
work
|
39
49
|
end
|
40
50
|
|
41
51
|
def self.bulk_requeue(units, _options)
|
@@ -55,7 +65,7 @@ module Sidekiq
|
|
55
65
|
job = redis.rpoplpush(queue.pending, queue.inproc)
|
56
66
|
return UnitOfWork.new(queue, job) if job
|
57
67
|
|
58
|
-
@exhausted.add(queue, :ttl =>
|
68
|
+
@exhausted.add(queue, :ttl => QUEUE_TIMEOUT)
|
59
69
|
end
|
60
70
|
end
|
61
71
|
|
@@ -64,17 +74,21 @@ module Sidekiq
|
|
64
74
|
end
|
65
75
|
|
66
76
|
def queues
|
67
|
-
(@strict ? @queues : @queues.shuffle.uniq) - exhausted
|
68
|
-
|
77
|
+
queues = (@strict ? @queues : @queues.shuffle.uniq) - @exhausted.to_a
|
78
|
+
|
79
|
+
# Avoid calling heavier `paused_queue` if there's nothing to filter out
|
80
|
+
return queues if queues.empty?
|
69
81
|
|
70
|
-
|
71
|
-
@exhausted.to_a
|
82
|
+
queues - paused_queues
|
72
83
|
end
|
73
84
|
|
74
85
|
def paused_queues
|
75
|
-
|
76
|
-
|
77
|
-
|
86
|
+
return @paused_queues if Time.now.to_i < @paused_queues_expires_at
|
87
|
+
|
88
|
+
@paused_queues.replace(Sidekiq::Throttled::QueuesPauser.instance.paused_queues.map { |q| QueueName[q] })
|
89
|
+
@paused_queues_expires_at = Time.now.to_i + 60
|
90
|
+
|
91
|
+
@paused_queues
|
78
92
|
end
|
79
93
|
end
|
80
94
|
end
|
@@ -32,7 +32,7 @@ module Sidekiq
|
|
32
32
|
# @param normalized [#to_s] Normalized (without any namespaces or `queue:`
|
33
33
|
# prefixes) queue name.
|
34
34
|
# @param identity [#to_s] Sidekiq process identity.
|
35
|
-
def initialize(normalized, identity:
|
35
|
+
def initialize(normalized, identity: Helper.identity)
|
36
36
|
@normalized = -normalized.to_s
|
37
37
|
@identity = -identity.to_s
|
38
38
|
end
|
@@ -113,10 +113,6 @@ module Sidekiq
|
|
113
113
|
def self.[](name, **kwargs)
|
114
114
|
new(name.to_s.sub(QUEUE_PREFIX_RE, "").freeze, **kwargs)
|
115
115
|
end
|
116
|
-
|
117
|
-
def self.process_identity
|
118
|
-
Helper.identity
|
119
|
-
end
|
120
116
|
end
|
121
117
|
end
|
122
118
|
end
|
data/sidekiq-ultimate.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
# this gem instead.
|
32
32
|
spec.add_runtime_dependency "sidekiq-throttled", "~> 0.8"
|
33
33
|
|
34
|
-
spec.add_development_dependency "bundler", "~>
|
34
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
35
35
|
|
36
36
|
spec.required_ruby_version = "~> 2.3"
|
37
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-ultimate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.alpha.
|
4
|
+
version: 0.0.1.alpha.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexey Zapparov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '2.0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '2.0'
|
97
97
|
description:
|
98
98
|
email:
|
99
99
|
- ixti@member.fsf.org
|
@@ -141,8 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
141
|
- !ruby/object:Gem::Version
|
142
142
|
version: 1.3.1
|
143
143
|
requirements: []
|
144
|
-
|
145
|
-
rubygems_version: 2.7.6
|
144
|
+
rubygems_version: 3.1.2
|
146
145
|
signing_key:
|
147
146
|
specification_version: 4
|
148
147
|
summary: Sidekiq ultimate experience.
|