Class: WhoCan::ConnectionWrapper
- Inherits:
-
Object
- Object
- WhoCan::ConnectionWrapper
- Includes:
- Deferred::Accessors, Logging
- Defined in:
- lib/who_can/connection_wrapper.rb
Overview
encapsulates the retry and failure detection logic. Used by ConnectionManager
Instance Attribute Summary collapse
-
#amqp_session ⇒ Object
readonly
Returns the value of attribute amqp_session.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#ekg ⇒ Object
readonly
Returns the value of attribute ekg.
-
#name ⇒ Object
Returns the value of attribute name.
-
#reconnect_delay ⇒ Object
how long should we wait between reconnection attempts.
-
#shutdown_timeout ⇒ Object
how long should we wait between reconnection attempts.
Instance Method Summary collapse
- #close(*a, &b) ⇒ Object
- #close!(*a, &b) ⇒ Object
-
#connect(*a, &b) ⇒ Object
XXX: figure out how to do this in a cleaner fashion.
- #connect!(*a, &b) ⇒ Object
-
#initialize(config, opts = {}) ⇒ ConnectionWrapper
constructor
A new instance of ConnectionWrapper.
Methods included from Logging
Constructor Details
#initialize(config, opts = {}) ⇒ ConnectionWrapper
Returns a new instance of ConnectionWrapper.
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/who_can/connection_wrapper.rb', line 79 def initialize(config, opts={}) @config = config @name = opts[:name] @reconnect_delay = opts[:reconnect_delay] || 5 @shutdown_timeout = opts[:shutdown_timeout] || 2.0 @ekg = nil @retry_count = 0 @amqp_session = nil @on_initial_connection_failure_cbs = [] super() end |
Instance Attribute Details
#amqp_session ⇒ Object (readonly)
Returns the value of attribute amqp_session.
13 14 15 |
# File 'lib/who_can/connection_wrapper.rb', line 13 def amqp_session @amqp_session end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
13 14 15 |
# File 'lib/who_can/connection_wrapper.rb', line 13 def config @config end |
#ekg ⇒ Object (readonly)
Returns the value of attribute ekg.
13 14 15 |
# File 'lib/who_can/connection_wrapper.rb', line 13 def ekg @ekg end |
#name ⇒ Object
Returns the value of attribute name.
15 16 17 |
# File 'lib/who_can/connection_wrapper.rb', line 15 def name @name end |
#reconnect_delay ⇒ Object
how long should we wait between reconnection attempts
18 19 20 |
# File 'lib/who_can/connection_wrapper.rb', line 18 def reconnect_delay @reconnect_delay end |
#shutdown_timeout ⇒ Object
how long should we wait between reconnection attempts
18 19 20 |
# File 'lib/who_can/connection_wrapper.rb', line 18 def shutdown_timeout @shutdown_timeout end |
Instance Method Details
#close(*a, &b) ⇒ Object
103 104 105 106 |
# File 'lib/who_can/connection_wrapper.rb', line 103 def close(*a, &b) on_close(&b) # hook deferred into this event super(*a) end |
#close!(*a, &b) ⇒ Object
108 109 110 111 |
# File 'lib/who_can/connection_wrapper.rb', line 108 def close!(*a, &b) on_close(&b) # hook deferred into this event super(*a) end |
#connect(*a, &b) ⇒ Object
XXX: figure out how to do this in a cleaner fashion
93 94 95 96 |
# File 'lib/who_can/connection_wrapper.rb', line 93 def connect(*a, &b) on_open(&b) super(*a) end |
#connect!(*a, &b) ⇒ Object
98 99 100 101 |
# File 'lib/who_can/connection_wrapper.rb', line 98 def connect!(*a, &b) on_open(&b) super(*a) end |