lib/amq/client/adapter.rb in amq-client-0.7.0.alpha23 vs lib/amq/client/adapter.rb in amq-client-0.7.0.alpha24
- old
+ new
@@ -14,33 +14,10 @@
#
# * #send_raw(data)
# * #estabilish_connection(settings)
# * #close_connection
#
- # Adapters also must indicate whether they operate in asynchronous or synchronous mode
- # using AMQ::Client::Adapter.sync accessor:
- #
- # @example EventMachine adapter indicates that it is asynchronous
- # module AMQ
- # module Client
- # class EventMachineClient
- #
- # #
- # # Behaviors
- # #
- #
- # include AMQ::Client::Adapter
- # include EventMachine::Deferrable
- #
- # self.sync = false
- #
- # # the rest of implementation code ...
- #
- # end
- # end
- # end
- #
# @abstract
module Adapter
def self.included(host)
host.extend(ClassMethods)
@@ -124,32 +101,11 @@
instance.register_connection_callback(&block)
instance
end
- # @see AMQ::Client::Adapter
- def sync=(boolean)
- @sync = boolean
- end
- # Use this method to detect whether adapter is synchronous or asynchronous.
- #
- # @return [Boolean] true if this adapter is synchronous
- # @api plugin
- # @see AMQ::Client::Adapter
- def sync?
- @sync == true
- end
-
- # @see #sync?
- # @api plugin
- # @see AMQ::Client::Adapter
- def async?
- !sync?
- end
-
-
# Can be overriden by higher-level libraries like amqp gem or bunny.
# Defaults to AMQ::Client::TCPConnectionFailed.
#
# @return [Class]
def tcp_connection_failure_exception_class
@@ -168,11 +124,11 @@
#
# Behaviors
#
- include AMQ::Client::StatusMixin
+ include AMQ::Client::Openable
extend RegisterEntityMixin
register_entity :channel, AMQ::Client::Channel
@@ -199,14 +155,10 @@
end
def handshake(mechanism = "PLAIN", response = "\0guest\0guest", locale = "en_GB")
self.send_preamble
self.connection = AMQ::Client::Connection.new(self, mechanism, response, locale)
- if self.sync?
- self.receive # Start/Start-Ok
- self.receive # Tune/Tune-Ok
- end
end
# Properly close connection with AMQ broker, as described in
# section 2.2.4 of the {http://bit.ly/hw2ELX AMQP 0.9.1 specification}.
#
@@ -277,11 +229,11 @@
frame = frames.first
if Protocol::HeartbeatFrame === frame
@last_server_heartbeat = Time.now
else
- callable = AMQ::Client::Entity.handlers[frame.method_class]
+ callable = AMQ::Client::HandlersRegistry.find(frame.method_class)
if callable
callable.call(self, frames.first, frames[1..-1])
else
raise MissingHandlerError.new(frames.first)
end
@@ -296,23 +248,9 @@
end
send(Protocol::HeartbeatFrame)
end
end # send_heartbeat
-
- # @see .sync?
- # @api plugin
- # @see AMQ::Client::Adapter
- def sync?
- self.class.sync?
- end
-
- # @see .async?
- # @api plugin
- # @see AMQ::Client::Adapter
- def async?
- self.class.async?
- end
# Returns heartbeat interval this client uses, in seconds.
# This value may or may not be used depending on broker capabilities.
#
# @return [Fixnum] Heartbeat interval this client uses, in seconds.