fluffle 0.5.0 → 0.5.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: c406204c168a6849d976d8154159052a8af28ce8
4
- data.tar.gz: 1c4da10c4f99f1226efe8ea2e294eeb96c4aeccb
3
+ metadata.gz: db3e03f956e60ac4f87c434246602395002447a7
4
+ data.tar.gz: 40ee39bde7ac04c765d33adde5987b00b6e9e4b5
5
5
  SHA512:
6
- metadata.gz: dfbcd74286bbb9f5eff6fbaec37bbaa4cebbd77658be972f3470fb694cba351d98dd97bdf5c810b298f0dde8721555841d8d7f3a39526e681723dd2e24c47bb3
7
- data.tar.gz: dab4d65da0025678e4315fe9bc94f411c5d1a2a520434e9a3d409a9b34c7907c00f50f98833f9984450dc2b25fb79d229096fbe5752bc893a015e587d307314c
6
+ metadata.gz: 87c4a5440bc2b373a82eed52b1810b58327b81a40d981bccbc065ffaf8694f6ac17e5b38504a344abe813f01f547794e177a30f4c859aad61b51354bb24fdc3b
7
+ data.tar.gz: caf718bbcfc70b2199a80bc93eadf05a088e0eb3a44004115d66b4d7de52fd916fbaf36c1b2cc46e74a99ff9d32bce8ab6bc83ce8b5dab451fe7633c7bf22267
data/examples/testing.rb CHANGED
@@ -13,7 +13,7 @@ end
13
13
 
14
14
  server.start
15
15
 
16
- client = Fluffle::Client.new url: 'amqp://localhost'
16
+ client = Fluffle::Client.new url: 'amqp://localhost', confirms: true
17
17
 
18
18
  timings = 10.times.map do
19
19
  t0 = Time.now
@@ -61,6 +61,8 @@ module Fluffle
61
61
  @instance ||= self.new
62
62
  end
63
63
 
64
+ attr_accessor :next_publish_seq_no
65
+
64
66
  def initialize
65
67
  @queues = Concurrent::Map.new
66
68
  end
@@ -111,30 +113,55 @@ module Fluffle
111
113
  class Channel
112
114
  def initialize(server)
113
115
  @server = server
116
+
117
+ @confirm_select = nil
118
+ @next_publish_seq_no = 0
114
119
  end
115
120
 
116
121
  def default_exchange
117
- @default_exchange ||= Exchange.new(@server)
122
+ @default_exchange ||= Exchange.new(@server, self)
118
123
  end
119
124
 
120
125
  def work_pool
121
126
  @work_pool ||= WorkPool.new
122
127
  end
123
128
 
129
+ def confirm_select(block = nil)
130
+ @confirm_select = block
131
+ @next_publish_seq_no = 1
132
+ end
133
+
134
+ def next_publish_seq_no
135
+ @next_publish_seq_no
136
+ end
137
+
124
138
  def queue(name, **opts)
125
139
  opts = opts.merge server: @server
126
140
 
127
141
  Queue.new name, opts
128
142
  end
143
+
144
+ def publish(payload, opts)
145
+ if @confirm_select
146
+ multiple = false
147
+ nack = false
148
+ @confirm_select.call @next_publish_seq_no, multiple, nack
149
+ end
150
+
151
+ @server.publish payload, opts
152
+
153
+ @next_publish_seq_no += 1 if @next_publish_seq_no > 0
154
+ end
129
155
  end
130
156
 
131
157
  class Exchange
132
- def initialize(server)
158
+ def initialize(server, channel)
133
159
  @server = server
160
+ @channel = channel
134
161
  end
135
162
 
136
163
  def publish(payload, opts)
137
- @server.publish(payload, opts)
164
+ @channel.publish payload, opts
138
165
  end
139
166
  end
140
167
 
@@ -1,3 +1,3 @@
1
1
  module Fluffle
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.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.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dirk Gadsden