fluffle 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9edeb50743d908defa90bd84bd3eb7fdb4e758d7
4
- data.tar.gz: 08e15dce619174c1d68a8cad7ef9f4594db34de7
3
+ metadata.gz: a9f71e19ecbc83b007dc32ccba31126d77eee04e
4
+ data.tar.gz: 02ed3772a88164c10941fc1ba349d6c48ac0bd2b
5
5
  SHA512:
6
- metadata.gz: 39a86ec46f7a0de63792e1331980fda6f0938fa14e465e69b08e12f8a50133b69bf072db4c1db73324fc201c8a9ac073cde88e65c0b43e195f03a5e4c5782725
7
- data.tar.gz: 16faf0e8c3196225712ada026f3bc6975f3c0fac79d38b9ebc93f509e898f82d020575b69867107ad0240f57b662b003e024919fa104a5d24f058b8a63f4f4e4
6
+ metadata.gz: 3f2c01c51733ebfc1abdc84e6748e714db2eacbb007a1dbb16a52ff1b9069162f839a615aa7bf439a262e283a34f8239789c33f6486dbadbb07c9c71fe44f471
7
+ data.tar.gz: 33f5912f93607cbda84ec8a48365126d9b974c7e3c76c1ab977a88e085c32bee107a8d9647f7112f0fd0e40ad2f6e81c5900ab631fcabd183a3cf22b28cfacc9
data/examples/server.rb CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  require 'fluffle'
5
5
 
6
- server = Fluffle::Server.new url: 'amqp://localhost', concurrency: 5, confirms: true
6
+ server = Fluffle::Server.new url: 'amqp://localhost', concurrency: 5, confirms: true, mandatory: true
7
7
 
8
8
  server.drain do |dispatcher|
9
9
  dispatcher.handle('foo') { 'bar' }
@@ -58,7 +58,7 @@ module Fluffle
58
58
  end
59
59
 
60
60
  def handle_returns
61
- @exchange.on_return do |return_info, properties, payload|
61
+ @exchange.on_return do |return_info, properties, _payload|
62
62
  id = properties[:correlation_id]
63
63
  ivar = @pending_responses.delete id
64
64
 
@@ -5,17 +5,18 @@ module Fluffle
5
5
  class Server
6
6
  include Connectable
7
7
 
8
- attr_reader :confirms, :connection, :handlers, :handler_pool
8
+ attr_reader :confirms, :connection, :handlers, :handler_pool, :mandatory
9
9
  attr_accessor :publish_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)
13
13
  # confirms: - Whether or not to use RabbitMQ confirms
14
- def initialize(url: nil, connection: nil, concurrency: 1, confirms: false)
14
+ def initialize(url: nil, connection: nil, concurrency: 1, confirms: false, mandatory: false)
15
15
  url_or_connection = url || connection
16
16
  self.connect(url_or_connection) if url_or_connection
17
17
 
18
18
  @confirms = confirms
19
+ @mandatory = mandatory
19
20
  @publish_timeout = 5
20
21
 
21
22
  @handlers = {}
@@ -46,11 +47,18 @@ module Fluffle
46
47
  @channel = @connection.create_channel
47
48
  @exchange = @channel.default_exchange
48
49
 
50
+ # Ensure we only receive 1 message at a time for each consumer
51
+ @channel.prefetch 1
52
+
49
53
  if confirms
50
54
  @confirmer = Fluffle::Confirmer.new channel: @channel
51
55
  @confirmer.confirm_select
52
56
  end
53
57
 
58
+ if mandatory
59
+ handle_returns
60
+ end
61
+
54
62
  raise 'No handlers defined' if @handlers.empty?
55
63
 
56
64
  @handlers.each do |name, handler|
@@ -76,6 +84,13 @@ module Fluffle
76
84
  self.wait_for_signal
77
85
  end
78
86
 
87
+ def handle_returns
88
+ @exchange.on_return do |return_info, _properties, _payload|
89
+ message = Kernel.sprintf "Received return from exchange for routing key `%s' (%d %s)", return_info.routing_key, return_info.reply_code, return_info.reply_text
90
+ Fluffle.logger.error "[Fluffle::Server] #{message}"
91
+ end
92
+ end
93
+
79
94
  # NOTE: Keeping this in its own method so its functionality can be more
80
95
  # easily overwritten by `Fluffle::Testing`.
81
96
  def wait_for_signal
@@ -1,3 +1,3 @@
1
1
  module Fluffle
2
- VERSION = '0.7.0'
2
+ VERSION = '0.7.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluffle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dirk Gadsden