Permalink
Browse files

Use the bunny-ext gem for the timeout monkey patching stuff

  • Loading branch information...
1 parent 84a2983 commit cf6bf3622b3a6e5c390234272ac3f18370d0f3ce @paukul committed Nov 19, 2010
Showing with 4 additions and 46 deletions.
  1. +2 −1 amqp_logging.gemspec
  2. +2 −1 lib/amqp_logging.rb
  3. +0 −44 lib/amqp_logging/ext/qrack/client.rb
@@ -36,7 +36,8 @@ Gem::Specification.new do |s|
INFO
s.specification_version = 3
- s.add_runtime_dependency("bunny", [">= 0.6.0"])
+ s.add_runtime_dependency("bunny", ["= 0.6.0"])
+ s.add_runtime_dependency("bunny-ext", ["= 0.6.0"])
s.add_runtime_dependency("activesupport", [">= 2.3.0"])
s.add_runtime_dependency("json", [">= 1.4.0"])
s.add_development_dependency("mocha", [">= 0"])
View
@@ -1,4 +1,5 @@
require 'bunny'
+require 'bunny-ext'
begin
# ActiveSupport 3.x
@@ -22,4 +23,4 @@ def self.iso_time_with_microseconds(t = Time.now)
require 'logger'
require 'amqp_logging/logger'
require 'amqp_logging/log_device'
-require 'amqp_logging/ext/qrack/client'
+
@@ -1,44 +0,0 @@
-require 'qrack/client'
-
-
-unless Qrack::Client.instance_methods.include?("socket_with_reliable_timeout")
- module AMQPLogging
- Timer = if RUBY_VERSION < "1.9"
- begin
- require 'system_timer'
- SystemTimer
- rescue LoadError
- require 'timeout'
- Timeout
- end
- else
- require 'timeout'
- Timeout
- end
- end
-
- module Qrack
- class Client
- # overwrite the timeout method so that SystemTimer is used
- # instead the standard timeout.rb: http://ph7spot.com/musings/system-timer
- delegate :timeout, :to => AMQPLogging::Timer
-
- def socket_with_reliable_timeout
- socket_without_reliable_timeout
-
- secs = Integer(CONNECT_TIMEOUT)
- usecs = Integer((CONNECT_TIMEOUT - secs) * 1_000_000)
- optval = [secs, usecs].pack("l_2")
-
- begin
- @socket.setsockopt Socket::SOL_SOCKET, Socket::SO_RCVTIMEO, optval
- @socket.setsockopt Socket::SOL_SOCKET, Socket::SO_SNDTIMEO, optval
- rescue Errno::ENOPROTOOPT
- end
- @socket
- end
- alias_method_chain :socket, :reliable_timeout
-
- end
- end
-end

0 comments on commit cf6bf36

Please sign in to comment.