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 +4 -4
- data/examples/testing.rb +1 -1
- data/lib/fluffle/testing.rb +30 -3
- data/lib/fluffle/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: db3e03f956e60ac4f87c434246602395002447a7
|
4
|
+
data.tar.gz: 40ee39bde7ac04c765d33adde5987b00b6e9e4b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87c4a5440bc2b373a82eed52b1810b58327b81a40d981bccbc065ffaf8694f6ac17e5b38504a344abe813f01f547794e177a30f4c859aad61b51354bb24fdc3b
|
7
|
+
data.tar.gz: caf718bbcfc70b2199a80bc93eadf05a088e0eb3a44004115d66b4d7de52fd916fbaf36c1b2cc46e74a99ff9d32bce8ab6bc83ce8b5dab451fe7633c7bf22267
|
data/examples/testing.rb
CHANGED
data/lib/fluffle/testing.rb
CHANGED
@@ -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
|
-
@
|
164
|
+
@channel.publish payload, opts
|
138
165
|
end
|
139
166
|
end
|
140
167
|
|
data/lib/fluffle/version.rb
CHANGED