Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Expose sync API for MQ#close (Channel.Close) [issue #34]

  * MQ#close can take a callback.
  • Loading branch information...
commit 7415747d9c8a48e6e8a7b8a9f2433d27a43a60d8 1 parent 69983df
Jakub Šťastný aka Botanicus authored
Showing with 17 additions and 1 deletion.
  1. +4 −1 lib/mq.rb
  2. +13 −0 spec/channel_close_spec.rb
View
5 lib/mq.rb
@@ -249,6 +249,8 @@ def process_frame frame
raise Error, "#{method.reply_text} in #{Protocol.classes[method.class_id].methods[method.method_id]} on #{@channel}"
when Protocol::Channel::CloseOk
+ @on_close && @on_close.call(self)
+
@closing = false
conn.callback{ |c|
c.channels.delete @channel
@@ -746,7 +748,8 @@ def rpc name, obj = nil
rpcs[name] ||= RPC.new(self, name, obj)
end
- def close
+ def close(&block)
+ @on_close = block
if @deferred_status == :succeeded
send Protocol::Channel::Close.new(:reply_code => 200,
:reply_text => 'bye',
View
13 spec/channel_close_spec.rb
@@ -0,0 +1,13 @@
+# encoding: utf-8
+
+require File.expand_path("../spec_helper", __FILE__)
+
+EM.describe "MQ#close(&callback)" do
+ default_timeout 5
+
+ should "take a callback which will run when we get back Channel.Close-Ok" do
+ MQ.new.close do |amq|
+ done
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.