pebbles-river 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pebbles/river/message.rb +9 -2
- data/lib/pebbles/river/supervisor.rb +22 -9
- data/lib/pebbles/river/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c159209a9e608dd1d740057e03daea124c650de
|
4
|
+
data.tar.gz: eae176e284a91579da4b4cdd4e06c202080d4c52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2799e6e6946b0b17b3c5722008e4a1c70365b3e00eae8b9fefeaa83bb213eaf864d2934591c2f49b08103998069c62167693fd54699068aea4b688aaef4e909c
|
7
|
+
data.tar.gz: e658cad4bb8ec8d75235915188eda161613fdef638ae5e321f50686c8d112bf43500878a815f1f90fb33366bce6fa48b0ec6b12e49f8dd539b042e1d1c40311c
|
@@ -32,6 +32,7 @@ module Pebbles
|
|
32
32
|
@queue = queue
|
33
33
|
@delivery_info = delivery_info
|
34
34
|
@payload = self.class.deserialize_payload(content)
|
35
|
+
@replied = false
|
35
36
|
end
|
36
37
|
|
37
38
|
def ==(other)
|
@@ -45,11 +46,17 @@ module Pebbles
|
|
45
46
|
end
|
46
47
|
|
47
48
|
def ack
|
48
|
-
|
49
|
+
if !@replied && (tag = delivery_tag)
|
50
|
+
@queue.channel.ack(tag)
|
51
|
+
@replied = true
|
52
|
+
end
|
49
53
|
end
|
50
54
|
|
51
55
|
def nack
|
52
|
-
|
56
|
+
if !@replied && (tag = delivery_tag)
|
57
|
+
@queue.channel.nack(tag, false, true)
|
58
|
+
@replied = true
|
59
|
+
end
|
53
60
|
end
|
54
61
|
|
55
62
|
end
|
@@ -60,10 +60,15 @@ module Pebbles
|
|
60
60
|
|
61
61
|
worker = Pebbles::River::Worker.new(listener, worker_options)
|
62
62
|
|
63
|
+
runner = ->() {
|
64
|
+
with_exception_logging do
|
65
|
+
worker.run
|
66
|
+
end
|
67
|
+
}
|
68
|
+
|
63
69
|
name = queue_spec[:name]
|
64
70
|
process_name = "#{@name}: queue worker: #{name}"
|
65
71
|
logger = @logger
|
66
|
-
|
67
72
|
@worker_modules.push([name, worker_count, Module.new {
|
68
73
|
define_method :execute do
|
69
74
|
$0 = process_name
|
@@ -72,7 +77,7 @@ module Pebbles
|
|
72
77
|
worker.stop
|
73
78
|
exit(0)
|
74
79
|
end
|
75
|
-
|
80
|
+
runner.call
|
76
81
|
end
|
77
82
|
}])
|
78
83
|
end
|
@@ -100,14 +105,10 @@ module Pebbles
|
|
100
105
|
|
101
106
|
# From Servolux::Server
|
102
107
|
def run
|
103
|
-
|
104
|
-
|
105
|
-
if logger.respond_to? :exception
|
106
|
-
logger.exception(e)
|
107
|
-
else
|
108
|
-
logger.error(e.inspect)
|
109
|
-
logger.error(e.backtrace.join("\n"))
|
108
|
+
with_exception_logging do
|
109
|
+
ensure_workers
|
110
110
|
end
|
111
|
+
sleep 1
|
111
112
|
end
|
112
113
|
|
113
114
|
private
|
@@ -161,6 +162,18 @@ module Pebbles
|
|
161
162
|
end
|
162
163
|
end
|
163
164
|
|
165
|
+
def with_exception_logging(&block)
|
166
|
+
yield
|
167
|
+
rescue => e
|
168
|
+
if logger.respond_to? :exception
|
169
|
+
logger.exception(e)
|
170
|
+
else
|
171
|
+
logger.error(e.inspect)
|
172
|
+
logger.error(e.backtrace.join("\n"))
|
173
|
+
end
|
174
|
+
raise
|
175
|
+
end
|
176
|
+
|
164
177
|
end
|
165
178
|
|
166
179
|
end
|