fluffle 0.7.2 → 0.8.0

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: 66afea53228678a471ae10c5e0182fd758f6da79
4
- data.tar.gz: bea8132d81c0ba7b48515f1be67da97154627369
3
+ metadata.gz: 3cf75bb5ed2a3dff720158c35fb96a604d27b14c
4
+ data.tar.gz: d0959935b67006ae17727560cab6bd745aa292d9
5
5
  SHA512:
6
- metadata.gz: e081cceefd2ff88dbc5ba31a65a909f8a9182dc9949f5585cbe752b107a7d53b76e36c69e2e789fcf7173efe4a1923bd461bfde5ce4f8290c0ba06a312588f77
7
- data.tar.gz: b81e4c8e44cc230099e5c7e94be1634b4d673e62febc6d90adb3d7322b0e7e21f4aa177a94825de3846bccb2a5d28c50a682b6fc04d7654af5d52a8d3f1fa963
6
+ metadata.gz: f4766339642a4e16397d855a640e3f8f07f702b17c9dea8dc6fcac70860840d35da1ff9caaceebdba46e45c8c96fdf7513c185bd64fe89b7992b25b110d452dd
7
+ data.tar.gz: 99c94b1f4a2fb4cb4b902fcf7c92186ddddc1e5533c1dfc140fdb643406b5bd045a5acf2d23d2129870f91a0418d97af1101ef0bd3b0d839bb94f37ad9c40f56
@@ -6,7 +6,7 @@ module Fluffle
6
6
  include Connectable
7
7
 
8
8
  attr_reader :confirms, :connection, :handlers, :handler_pool, :mandatory
9
- attr_accessor :publish_timeout
9
+ attr_accessor :publish_timeout, :shutdown_timeout
10
10
 
11
11
  # url: - Optional URL to pass to `Bunny.new` to immediately connect
12
12
  # concurrency: - Number of threads to handle messages on (default: 1)
@@ -15,9 +15,10 @@ module Fluffle
15
15
  url_or_connection = url || connection
16
16
  self.connect(url_or_connection) if url_or_connection
17
17
 
18
- @confirms = confirms
19
- @mandatory = mandatory
20
- @publish_timeout = 5
18
+ @confirms = confirms
19
+ @mandatory = mandatory
20
+ @publish_timeout = 5
21
+ @shutdown_timeout = 15
21
22
 
22
23
  @handlers = {}
23
24
  @handler_pool = Concurrent::FixedThreadPool.new concurrency
@@ -68,14 +69,14 @@ module Fluffle
68
69
  queue.subscribe(manual_ack: true) do |delivery_info, properties, payload|
69
70
  @handler_pool.post do
70
71
  begin
71
- @channel.ack delivery_info.delivery_tag
72
-
73
72
  handle_request handler: handler,
74
73
  properties: properties,
75
74
  payload: payload
76
75
  rescue => err
77
76
  # Ensure we don't loose any errors on the handler pool's thread
78
77
  Fluffle.logger.error "[Fluffle::Server] #{err.class}: #{err.message}\n#{err.backtrace.join("\n")}"
78
+ ensure
79
+ @channel.ack delivery_info.delivery_tag
79
80
  end
80
81
  end
81
82
  end
@@ -109,8 +110,16 @@ module Fluffle
109
110
  signal = readables.first.gets.strip
110
111
 
111
112
  Fluffle.logger.info "Received #{signal}; shutting down..."
113
+
112
114
  @channel.work_pool.shutdown
113
115
 
116
+ @handler_pool.shutdown
117
+ unless @handler_pool.wait_for_termination(@shutdown_timeout)
118
+ # `wait_for_termination` returns false if it didn't shut down in time,
119
+ # so we need to kill it
120
+ @handler_pool.kill
121
+ end
122
+
114
123
  return
115
124
  end
116
125
  end
@@ -1,3 +1,3 @@
1
1
  module Fluffle
2
- VERSION = '0.7.2'
2
+ VERSION = '0.8.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluffle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dirk Gadsden
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-01 00:00:00.000000000 Z
11
+ date: 2016-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny