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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 824aaae9f843edae29e1d76e21fa69a575ff2e47
4
- data.tar.gz: 7b387043e25d6227a60f640ec988e73ee724e46a
3
+ metadata.gz: 38ebbf8e4e71e1ce0ae67c1aca670320ea0d6e86
4
+ data.tar.gz: ac04a93240de4a8f3ee9bda2900272f6cd7020e5
5
5
  SHA512:
6
- metadata.gz: e234f53cec985f83a88d22bf4aad67a6b269cc4987edca3e30aa91fbed1bf51540d8735c9f6c338cd05520895879ef718912a53efce85e18901f0cd2c249d174
7
- data.tar.gz: e3a8601d48936dfd55c2bec6fda15343d6bb520b649d0a92dcf7841dbc967773688b0d335a21fa5fab5be80d1aab0929e9d05260ecfbeba57ec42ce57e2bd13b
6
+ metadata.gz: 0b571056ef4af2e385cb2f7aa53b26d4fd3e20d5177df7d6e72168ce2fb4eb291e1b00fe40c97b112e9fcc3484e9a9c4d5a38efe437c6cf53b0b7ed5f008d8a4
7
+ data.tar.gz: 51d6b3e43835c5d82e16cb85a952fd5a200d9f99762954c0658f168cb0bf3fe05757f033448fee7112c59d0123ec2b109ee09fdcec2872c02b53870a20defa49
@@ -1,5 +1,5 @@
1
1
  if defined?(Resque::Worker)
2
2
  Resque.send(:extend, Resque::Additions)
3
- #Resque::Worker.send(:include, Resque::DynamicQueues)
3
+ Resque::Worker.send(:include, Resque::DynamicQueues)
4
4
  Resque::Job.send(:include, Resque::SelfLookup)
5
5
  end
@@ -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 true || Rails.env != 'development' && !ENV['DEIS_APP'].blank?
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
@@ -1,3 +1,3 @@
1
1
  module ZuoraConnect
2
- VERSION = "1.5.04"
2
+ VERSION = "1.5.05"
3
3
  end
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.04
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-16 00:00:00.000000000 Z
11
+ date: 2017-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: apartment