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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b095f1ed2b6aff2c1d4916c73503981169c7ac5a
4
- data.tar.gz: f69bdbd2bc4cef2a857bc84555eb83342b1ed699
3
+ metadata.gz: 4c159209a9e608dd1d740057e03daea124c650de
4
+ data.tar.gz: eae176e284a91579da4b4cdd4e06c202080d4c52
5
5
  SHA512:
6
- metadata.gz: e8e8da724df5dcaafd4d1f1acdb9a0b5dc7fa2a93e2cb01af110f5522a42b203bc011e8c2953f4f50057840cee1a9e0d1aa6a9f659c99f01a80926c67def385a
7
- data.tar.gz: 49e9212ea4c0b3db87894dc15f6d9b2769e8f947f164cdcc1213dd7bf5d71321c9f27de4baccf078e0da9b85b64684baaadea8cbf9fac4fe95fe162ecaf9246c
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
- @queue.channel.ack(delivery_tag)
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
- @queue.channel.nack(delivery_tag, false, true)
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
- worker.run
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
- ensure_workers
104
- rescue => e
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
@@ -1,5 +1,5 @@
1
1
  module Pebbles
2
2
  module River
3
- VERSION = '0.3.5'
3
+ VERSION = '0.3.6'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pebbles-river
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Staubo