zuora_connect 1.5.04 → 1.5.05
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/config/initializers/resque.rb +1 -1
- data/lib/resque/dynamic_queues.rb +58 -0
- data/lib/zuora_connect/railtie.rb +1 -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: 38ebbf8e4e71e1ce0ae67c1aca670320ea0d6e86
|
|
4
|
+
data.tar.gz: ac04a93240de4a8f3ee9bda2900272f6cd7020e5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0b571056ef4af2e385cb2f7aa53b26d4fd3e20d5177df7d6e72168ce2fb4eb291e1b00fe40c97b112e9fcc3484e9a9c4d5a38efe437c6cf53b0b7ed5f008d8a4
|
|
7
|
+
data.tar.gz: 51d6b3e43835c5d82e16cb85a952fd5a200d9f99762954c0658f168cb0bf3fe05757f033448fee7112c59d0123ec2b109ee09fdcec2872c02b53870a20defa49
|
|
@@ -1,5 +1,61 @@
|
|
|
1
1
|
module Resque
|
|
2
2
|
module DynamicQueues
|
|
3
|
+
def filter_busy_queues qs
|
|
4
|
+
busy_queues = Resque::Worker.working.map { |worker| worker.job["queue"] }.compact
|
|
5
|
+
Array(qs.dup).compact - busy_queues
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def rotated_queues
|
|
9
|
+
@n ||= 0
|
|
10
|
+
@n += 1
|
|
11
|
+
rot_queues = queues # since we rely on the resque-dynamic-queues plugin, this is all the queues, expanded out
|
|
12
|
+
if rot_queues.size > 0
|
|
13
|
+
@n = @n % rot_queues.size
|
|
14
|
+
rot_queues.rotate(@n)
|
|
15
|
+
else
|
|
16
|
+
rot_queues
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def queue_depth queuename
|
|
21
|
+
busy_queues = Resque::Worker.working.map { |worker| worker.job["queue"] }.compact
|
|
22
|
+
# find the queuename, count it.
|
|
23
|
+
busy_queues.select {|q| q == queuename }.size
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
DEFAULT_QUEUE_DEPTH = 0
|
|
27
|
+
def should_work_on_queue? queuename
|
|
28
|
+
return true if @queues.include? '*' # workers with QUEUES=* are special and are not subject to queue depth setting
|
|
29
|
+
max = DEFAULT_QUEUE_DEPTH
|
|
30
|
+
unless ENV["RESQUE_QUEUE_DEPTH"].nil? || ENV["RESQUE_QUEUE_DEPTH"] == ""
|
|
31
|
+
max = ENV["RESQUE_QUEUE_DEPTH"].to_i
|
|
32
|
+
end
|
|
33
|
+
return true if max == 0 # 0 means no limiting
|
|
34
|
+
cur_depth = queue_depth(queuename)
|
|
35
|
+
log! "queue #{queuename} depth = #{cur_depth} max = #{max}"
|
|
36
|
+
return true if cur_depth < max
|
|
37
|
+
false
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def reserve_with_round_robin
|
|
41
|
+
qs = rotated_queues
|
|
42
|
+
qs.each do |queue|
|
|
43
|
+
log! "Checking #{queue}"
|
|
44
|
+
if should_work_on_queue?(queue) && @job_in_progress = Resque::Job.reserve(queue)
|
|
45
|
+
log! "Found job on #{queue}"
|
|
46
|
+
return @job_in_progress
|
|
47
|
+
end
|
|
48
|
+
# Start the next search at the queue after the one from which we pick a job.
|
|
49
|
+
@n += 1
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
nil
|
|
53
|
+
rescue Exception => e
|
|
54
|
+
log "Error reserving job: #{e.inspect}"
|
|
55
|
+
log e.backtrace.join("\n")
|
|
56
|
+
raise e
|
|
57
|
+
end
|
|
58
|
+
|
|
3
59
|
# Returns a list of queues to use when searching for a job.
|
|
4
60
|
#
|
|
5
61
|
# A splat ("*") means you want every queue (in alpha order) - this
|
|
@@ -67,6 +123,8 @@ module Resque
|
|
|
67
123
|
receiver.class_eval do
|
|
68
124
|
alias queues_without_dynamic queues
|
|
69
125
|
alias queues queues_with_dynamic
|
|
126
|
+
alias reserve_without_round_robin reserve
|
|
127
|
+
alias reserve reserve_with_round_robin
|
|
70
128
|
end
|
|
71
129
|
end
|
|
72
130
|
end
|
|
@@ -13,7 +13,7 @@ module ZuoraConnect
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
initializer(:rails_stdout_logging, before: :initialize_logger) do
|
|
16
|
-
if
|
|
16
|
+
if Rails.env != 'development' && !ENV['DEIS_APP'].blank?
|
|
17
17
|
require 'lograge'
|
|
18
18
|
logger = ActiveSupport::Logger.new(STDOUT)
|
|
19
19
|
logger.formatter = ::Logger::Formatter.new
|
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.5.
|
|
4
|
+
version: 1.5.05
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Connect Team
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-12-
|
|
11
|
+
date: 2017-12-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: apartment
|