From 0aab60ba09a020451248d7a17d147b26695994bf Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Thu, 27 Jan 2011 10:19:24 +0000 Subject: [PATCH] renamed AMQP::Failover::BasicClient to AMQP::FailoverClient --- lib/amqp/failover.rb | 2 +- lib/amqp/failover/basic_client.rb | 55 ------------------------------- lib/amqp/failover_client.rb | 51 ++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 56 deletions(-) delete mode 100644 lib/amqp/failover/basic_client.rb create mode 100644 lib/amqp/failover_client.rb diff --git a/lib/amqp/failover.rb b/lib/amqp/failover.rb index 4cf5bf6..9bbac6c 100644 --- a/lib/amqp/failover.rb +++ b/lib/amqp/failover.rb @@ -2,7 +2,7 @@ require 'yaml' -require 'amqp/failover/basic_client' +require 'amqp/failover_client' require 'amqp/failover/config' require 'amqp/failover/fallback' require 'amqp/failover/logger' diff --git a/lib/amqp/failover/basic_client.rb b/lib/amqp/failover/basic_client.rb deleted file mode 100644 index c558829..0000000 --- a/lib/amqp/failover/basic_client.rb +++ /dev/null @@ -1,55 +0,0 @@ -# encoding: utf-8 - -module AMQP - module Failover - module BasicClient - include AMQP::BasicClient - - class Error < Exception; end - - attr_accessor :on_disconnect - attr_accessor :settings - - def self.extended(base) - base.on_disconnect = proc { - OnDisconnect.new(base).call - } - end - - def logger - @logger ||= Logger.new - end - - def failover_conf - @failover_conf ||= Config.new - end - - def configs - failover_conf.configs - end - - def clean_exit(msg = nil) - msg ||= "clean exit" - logger.info(msg) - logger.error(msg) - Process.exit - end - - def process_frame(frame) - if mq = channels[frame.channel] - mq.process_frame(frame) - return - end - - if frame.is_a?(::AMQP::Frame::Method) && (method = frame.payload).is_a?(::AMQP::Protocol::Connection::Close) - if method.reply_text =~ /^NOT_ALLOWED/ - raise ::AMQP::Error, "#{method.reply_text} in #{::AMQP::Protocol.classes[method.class_id].methods[method.method_id]}" - end - end - super(frame) - end - - end # BasicClient - end # Failover -end # AMQP - diff --git a/lib/amqp/failover_client.rb b/lib/amqp/failover_client.rb new file mode 100644 index 0000000..f69a6a3 --- /dev/null +++ b/lib/amqp/failover_client.rb @@ -0,0 +1,51 @@ +# encoding: utf-8 + +module AMQP + module FailoverClient + include AMQP::BasicClient + + attr_accessor :on_disconnect + attr_accessor :settings + + def self.extended(base) + base.on_disconnect = proc { + Failover::OnDisconnect.new(base).call + } + end + + def logger + @logger ||= Failover::Logger.new + end + + def failover_conf + @failover_conf ||= Failover::Config.new + end + + def configs + failover_conf.configs + end + + def clean_exit(msg = nil) + msg ||= "clean exit" + logger.info(msg) + logger.error(msg) + Process.exit + end + + def process_frame(frame) + if mq = channels[frame.channel] + mq.process_frame(frame) + return + end + + if frame.is_a?(AMQP::Frame::Method) && (method = frame.payload).is_a?(AMQP::Protocol::Connection::Close) + if method.reply_text =~ /^NOT_ALLOWED/ + raise AMQP::Error, "#{method.reply_text} in #{::AMQP::Protocol.classes[method.class_id].methods[method.method_id]}" + end + end + super(frame) + end + + end # FailoverClient +end # AMQP +