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 +4 -4
- data/lib/osbourne/launcher.rb +11 -7
- data/lib/osbourne/version.rb +1 -1
- data/lib/osbourne/worker_base.rb +3 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cc955a9e0ea8360e5f14cb22de9f7d48c56b0607a66652bfe0410a712b7d17d
|
4
|
+
data.tar.gz: 605a96f1cd91e57a572fb235c4e1e95d75a37d31b776dce4870658d300cb2f15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a74fc022d08f297ff54e6aff4192fa8126a4f93d96ee8118faec2a1f21f046deb12e4d4c272cfc863460d9efcff41262671f34948c73a94d6c3cf9ac1cd09f48
|
7
|
+
data.tar.gz: 97f79d13c2b3440f8528fdd767e537f0fdc1ae5f6a61cd2dbd9129d97920b5ae7c80b819c1a0e69e44755f9c07e2795b9d759cdf12ad78395e66b0139c9a5633
|
data/lib/osbourne/launcher.rb
CHANGED
@@ -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
|
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.
|
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
|
data/lib/osbourne/version.rb
CHANGED
data/lib/osbourne/worker_base.rb
CHANGED
@@ -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
|