Class: Fluffle::Testing::Loopback::Channel
- Inherits:
-
Object
- Object
- Fluffle::Testing::Loopback::Channel
- Defined in:
- lib/fluffle/testing.rb
Instance Method Summary collapse
- #confirm_select(block = nil) ⇒ Object
- #default_exchange ⇒ Object
-
#initialize(server) ⇒ Channel
constructor
A new instance of Channel.
- #next_publish_seq_no ⇒ Object
- #publish(payload, opts) ⇒ Object
- #queue(name, **opts) ⇒ Object
- #work_pool ⇒ Object
Constructor Details
#initialize(server) ⇒ Channel
Returns a new instance of Channel.
114 115 116 117 118 119 |
# File 'lib/fluffle/testing.rb', line 114 def initialize(server) @server = server @confirm_select = nil @next_publish_seq_no = 0 end |
Instance Method Details
#confirm_select(block = nil) ⇒ Object
129 130 131 132 |
# File 'lib/fluffle/testing.rb', line 129 def confirm_select(block = nil) @confirm_select = block @next_publish_seq_no = 1 end |
#default_exchange ⇒ Object
121 122 123 |
# File 'lib/fluffle/testing.rb', line 121 def default_exchange @default_exchange ||= Exchange.new(@server, self) end |
#next_publish_seq_no ⇒ Object
134 135 136 |
# File 'lib/fluffle/testing.rb', line 134 def next_publish_seq_no @next_publish_seq_no end |
#publish(payload, opts) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/fluffle/testing.rb', line 144 def publish(payload, opts) if @confirm_select multiple = false nack = false @confirm_select.call @next_publish_seq_no, multiple, nack end @server.publish payload, opts @next_publish_seq_no += 1 if @next_publish_seq_no > 0 end |
#queue(name, **opts) ⇒ Object
138 139 140 141 142 |
# File 'lib/fluffle/testing.rb', line 138 def queue(name, **opts) opts = opts.merge server: @server Queue.new name, opts end |
#work_pool ⇒ Object
125 126 127 |
# File 'lib/fluffle/testing.rb', line 125 def work_pool @work_pool ||= WorkPool.new end |