Sha256: 89c3684cb9adc845f600a25612ddb772d24e1947afb6a870e5f62ee0e10a631d
Contents?: true
Size: 1.01 KB
Versions: 3
Compression:
Stored size: 1.01 KB
Contents
module Waffle module Transports class Base attr_reader :config def initialize config @config = config connect! end def publish flow = 'events', message = '' publish_impl(flow, message) rescue *connection_exceptions => e reconnect && retry if ready_to_connect? end def subscribe flow = '', &block subscribe_impl(flow, &block) rescue *connection_exceptions => e until reconnect do sleep(config.connection_attempt_timeout) end retry end protected def ready_to_connect? (Time.now - @last_connection_attempt) > config.connection_attempt_timeout end def reconnect connect! end def encoder @encoder ||= "Waffle::Encoders::#{config.encoder.camelize}".constantize end def connect! @last_connection_attempt = Time.now do_connect rescue false end def do_connect end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
waffle-0.6.0 | lib/waffle/transports/base.rb |
waffle-0.5.1 | lib/waffle/transports/base.rb |
waffle-0.5.0 | lib/waffle/transports/base.rb |