zuora_connect 1.7.52 → 1.7.53
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/resque/dynamic_queues.rb +70 -12
- data/lib/zuora_connect/configuration.rb +2 -1
- data/lib/zuora_connect/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fdd106c26a1f27acc4ec9aefb5aeb5e918803e1
|
4
|
+
data.tar.gz: 65b36ddcff35db5adbaf7e8a77c8eede3a934a22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ada77e860004fcfe14dbc826e5e8ce636917ef372d9e7e78ce8c88bf85f0314ece2ad64aeea0bcf2d874a1fb82a00bcde7453ff89f905f0aca625ebc93de490e
|
7
|
+
data.tar.gz: 9b9594b3149efa9b9fd075bf8f5db2c9d4423fb1e8499f61167a1eec995f68fcaead6ab2edeef101b603ab41035c777366af10d25a6fe00a2cb5b520811c5ef6
|
@@ -58,22 +58,26 @@ module Resque
|
|
58
58
|
|
59
59
|
#Instance queue grouping
|
60
60
|
if !grouped_queues.keys.include?(nil) && grouped_queues.keys.size > 0
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
61
|
+
if ZuoraConnect.configuration.blpop_queue
|
62
|
+
return get_job(grouped_queues)
|
63
|
+
else
|
64
|
+
@n ||= 0
|
65
|
+
@n += 1
|
66
|
+
@n = @n % grouped_queues.keys.size
|
67
|
+
grouped_queues.keys.rotate(@n).each do |key|
|
68
|
+
self.get_categorized_queues(grouped_queues[key]).each do |key, queues|
|
69
|
+
queues.each do |queue|
|
70
|
+
log! "Checking #{queue}"
|
71
|
+
if should_work_on_queue?(queue) && @job_in_progress = Resque::Job.reserve(queue)
|
72
|
+
log! "Found job on #{queue}"
|
73
|
+
return @job_in_progress
|
74
|
+
end
|
71
75
|
end
|
72
76
|
end
|
77
|
+
@n += 1 # Start the next search at the queue after the one from which we pick a job.
|
73
78
|
end
|
74
|
-
|
79
|
+
nil
|
75
80
|
end
|
76
|
-
nil
|
77
81
|
else
|
78
82
|
return reserve_without_round_robin
|
79
83
|
end
|
@@ -84,6 +88,60 @@ module Resque
|
|
84
88
|
raise e
|
85
89
|
end
|
86
90
|
|
91
|
+
def create_job(queue, payload)
|
92
|
+
return unless payload
|
93
|
+
Resque::Job.new(queue, payload)
|
94
|
+
end
|
95
|
+
|
96
|
+
def get_job(grouped_queues)
|
97
|
+
get_restricted_job
|
98
|
+
get_queued_job(grouped_queues)
|
99
|
+
end
|
100
|
+
|
101
|
+
def get_next_job(grouped_queues)
|
102
|
+
@n ||= 0
|
103
|
+
queue_index = {}
|
104
|
+
grouped_queues.each_with_index do |(key, queue_list), index|
|
105
|
+
queue_list.each do |queue|
|
106
|
+
queue_index[queue] = index
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
grouped_queues = grouped_queues.values.rotate(@n).map{|queue_list| get_categorized_queues(queue_list).to_h.values.flatten}.flatten.delete_if{|queue| !should_work_on_queue?(queue)}.map{|queue| "queue:#{queue}"}
|
111
|
+
queue, payload = Resque.redis.blpop(grouped_queues)
|
112
|
+
queue = queue.split("queue:")[1]
|
113
|
+
@n = queue_index[queue] + 1
|
114
|
+
return create_job(queue, Resque.decode(payload))
|
115
|
+
end
|
116
|
+
|
117
|
+
def get_restricted_job
|
118
|
+
Resque::Plugins::ConcurrentRestrictionJob.next_runnable_job_random
|
119
|
+
end
|
120
|
+
|
121
|
+
def get_queued_job(grouped_queues)
|
122
|
+
# Bounded retry
|
123
|
+
1.upto(Resque::Plugins::ConcurrentRestriction.reserve_queued_job_attempts) do |i|
|
124
|
+
resque_job = get_next_job(grouped_queues)
|
125
|
+
|
126
|
+
# Short-curcuit if a job was not found
|
127
|
+
return if resque_job.nil?
|
128
|
+
|
129
|
+
# If there is a job on regular queues, then only run it if its not restricted
|
130
|
+
job_class = resque_job.payload_class
|
131
|
+
job_args = resque_job.args
|
132
|
+
|
133
|
+
# Return to work on job if not a restricted job
|
134
|
+
return resque_job unless job_class.is_a?(ConcurrentRestriction)
|
135
|
+
|
136
|
+
# Keep trying if job is restricted. If job is runnable, we keep the lock until
|
137
|
+
# done_working
|
138
|
+
return resque_job unless job_class.stash_if_restricted(resque_job)
|
139
|
+
end
|
140
|
+
|
141
|
+
# Safety net, here in case we hit the upper bound and there are still queued items
|
142
|
+
return nil
|
143
|
+
end
|
144
|
+
|
87
145
|
# Returns a list of queues to use when searching for a job.
|
88
146
|
#
|
89
147
|
# A splat ("*") means you want every queue (in alpha order) - this
|
@@ -3,7 +3,7 @@ module ZuoraConnect
|
|
3
3
|
|
4
4
|
attr_accessor :default_locale, :default_time_zone, :url, :mode, :delayed_job,:private_key, :additional_apartment_models
|
5
5
|
|
6
|
-
attr_accessor :enable_metrics, :telegraf_endpoint, :telegraf_debug, :custom_prometheus_update_block, :silencer_resque_finish
|
6
|
+
attr_accessor :enable_metrics, :telegraf_endpoint, :telegraf_debug, :custom_prometheus_update_block, :silencer_resque_finish, :blpop_queue
|
7
7
|
|
8
8
|
attr_accessor :oauth_client_id, :oauth_client_secret, :oauth_client_redirect_uri
|
9
9
|
|
@@ -18,6 +18,7 @@ module ZuoraConnect
|
|
18
18
|
@private_key = ENV["CONNECT_KEY"]
|
19
19
|
@additional_apartment_models = []
|
20
20
|
@silencer_resque_finish = true
|
21
|
+
@blpop_queue = false
|
21
22
|
|
22
23
|
# Setting the app name for telegraf write
|
23
24
|
@enable_metrics = false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zuora_connect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.53
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Connect Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apartment
|