osbourne 1.1.6 → 1.2

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: 0601b6c1105b1ee73019fd9d0776cc1dce5cf02370c84120780be45344c17c68
4
- data.tar.gz: 771b77ff9768e57d92cce22ca7b9aa79aaf60a4772b8cc009efb04d4593f28ca
3
+ metadata.gz: 4cc955a9e0ea8360e5f14cb22de9f7d48c56b0607a66652bfe0410a712b7d17d
4
+ data.tar.gz: 605a96f1cd91e57a572fb235c4e1e95d75a37d31b776dce4870658d300cb2f15
5
5
  SHA512:
6
- metadata.gz: ab8b46e9adbb97518e776a16cd488997a446ab1ce9b3e6504bf3a24e5d8a5d51a0e4d036c1d0f14ae366c4389b78cc0ce37a01ce7166411d92d1ad91ef94c03f
7
- data.tar.gz: 158fa1e740d28ac8a14ca3a506a7ef6da7d6e3b4d877baf378ca06b0b869fe2aec40ddd9c8e5080bf05c79b4f63d54708bf2bc3aaeb5990531c089c27b576f16
6
+ metadata.gz: a74fc022d08f297ff54e6aff4192fa8126a4f93d96ee8118faec2a1f21f046deb12e4d4c272cfc863460d9efcff41262671f34948c73a94d6c3cf9ac1cd09f48
7
+ data.tar.gz: 97f79d13c2b3440f8528fdd767e537f0fdc1ae5f6a61cd2dbd9129d97920b5ae7c80b819c1a0e69e44755f9c07e2795b9d759cdf12ad78395e66b0139c9a5633
@@ -30,7 +30,12 @@ module Osbourne
30
30
  def global_polling_threads
31
31
  Osbourne::WorkerBase.descendants.map do |worker|
32
32
  Osbourne.logger.debug("[Osbourne] Spawning thread for #{worker.name}")
33
- Thread.new { poll(worker) }
33
+ Thread.new do
34
+ loop do
35
+ poll(worker)
36
+ break if @stop
37
+ end
38
+ end
34
39
  end
35
40
  end
36
41
 
@@ -45,28 +50,27 @@ module Osbourne
45
50
  def poll(worker)
46
51
  worker.polling_queue.poll(wait_time_seconds: worker.config[:max_wait_time],
47
52
  max_number_of_messages: worker.config[:max_batch_size],
53
+ idle_timeout: worker.config[:idle_timeout],
48
54
  skip_delete: true) do |messages|
49
55
  Osbourne.logger.debug("[Osbourne] Recieved #{messages.count} on #{worker.name}")
50
- messages.map do |msg|
51
- worker.polling_queue.delete_message(msg) if process(worker, Osbourne::Message.new(msg))
52
- end
53
- Osbourne.logger.debug("[Osbourne] Waiting for more messages on #{worker.name} for max of #{worker.config[:max_wait_time]} seconds")
56
+ Array(messages).each {|msg| process(worker, Osbourne::Message.new(msg)) }
54
57
  throw :stop_polling if @stop
58
+ Osbourne.logger.debug("[Osbourne] Waiting for more messages on #{worker.name} for max of #{worker.config[:max_wait_time]} seconds")
55
59
  end
56
60
  end
57
61
 
58
62
  private
59
63
 
60
- def process(worker, message)
64
+ def process(worker, message) # rubocop:disable Metrics/AbcSize
61
65
  Osbourne.logger.info("[Osbourne] [MSG] Worker: #{worker.name} Valid: #{message.valid?} ID: #{message.id}")
62
66
  return false unless message.valid? && Osbourne.lock.soft_lock(message.id)
63
67
 
64
68
  Osbourne.cache.fetch(message.id, ex: 24.hours) do
65
69
  worker.new.process(message).tap {|_| Osbourne.lock.unlock(message.id) }
66
70
  end
71
+ worker.polling_queue.delete_message(message.message)
67
72
  rescue Exception => ex # rubocop:disable Lint/RescueException
68
73
  Osbourne.logger.error("[Osbourne] [MSG ID: #{message.id}] [#{ex.message}]\n #{ex.backtrace_locations.join("\n")}")
69
- false
70
74
  end
71
75
  end
72
76
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Osbourne
4
- VERSION = "1.1.6"
4
+ VERSION = "1.2"
5
5
  end
@@ -79,6 +79,7 @@ module Osbourne
79
79
  threads: Osbourne.threads_per_worker,
80
80
  queue_name: default_queue_name,
81
81
  dead_letter_queue: true,
82
+ idle_timeout: 600,
82
83
  max_retry_count: Osbourne.max_retry_count)
83
84
  self.config = {
84
85
  topic_names: Array(topics),
@@ -87,7 +88,8 @@ module Osbourne
87
88
  max_wait: max_wait,
88
89
  threads: threads,
89
90
  dead_letter: dead_letter_queue,
90
- max_retry_count: max_retry_count
91
+ max_retry_count: max_retry_count,
92
+ idle_timeout: idle_timeout
91
93
  }
92
94
  end
93
95
  # rubocop:enable Metrics/ParameterLists
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osbourne
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
4
+ version: '1.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Allen