Sha256: 3b2915c77b0eb49210d0baebb11bc11b1cd3ebba150343cec911d7a957d5e9bb
Contents?: true
Size: 1.07 KB
Versions: 3
Compression:
Stored size: 1.07 KB
Contents
# encoding: utf-8 module AMQP class Failover class ServerDiscovery < EM::Connection class << self attr_accessor :connection end def self.monitor(conf = {}, retry_interval = nil, &block) if EM.reactor_running? start_monitoring(conf, retry_interval, &block) else EM.run { start_monitoring(conf, retry_interval, &block) } end end def initialize(args) @done = args[:done] @timer = args[:timer] end def connection_completed @done.call @timer.cancel close_connection end def self.start_monitoring(conf = {}, retry_interval = nil, &block) conf = conf.clone retry_interval ||= 5 conf[:done] = block conf[:timer] = EM::PeriodicTimer.new(retry_interval) do @connection = connect(conf) end end def self.connect(conf) EM.connect(conf[:host], conf[:port], self, conf) end end # ServerDiscovery end # Failover end # AMQP
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
amqp-failover-0.0.3 | lib/amqp/failover/server_discovery.rb |
amqp-failover-0.0.2 | lib/amqp/failover/server_discovery.rb |
amqp-failover-0.0.1 | lib/amqp/failover/server_discovery.rb |