Class: JackRabbit::Connection
- Inherits:
-
Object
- Object
- JackRabbit::Connection
- Defined in:
- lib/jack_rabbit/connection.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ connection_timeout: 5, heartbeat_interval: 5 }
Constants included from Logging
Constants included from Backoff
Instance Method Summary collapse
- #channel(options) ⇒ Object
- #close ⇒ Object
- #create_channel ⇒ Object
-
#initialize(uri, options) ⇒ Connection
constructor
A new instance of Connection.
- #open ⇒ Object
- #reopen(reason) ⇒ Object
Methods included from Logging
Methods included from Backoff
Constructor Details
#initialize(uri, options) ⇒ Connection
Returns a new instance of Connection.
13 14 15 16 |
# File 'lib/jack_rabbit/connection.rb', line 13 def initialize(uri, ) @uri, @options = uri, .merge((uri)) @channels = [] end |
Instance Method Details
#channel(options) ⇒ Object
27 28 29 30 31 |
# File 'lib/jack_rabbit/connection.rb', line 27 def channel() channel = Channel.new(self, ) @channels << channel channel end |
#close ⇒ Object
23 24 25 |
# File 'lib/jack_rabbit/connection.rb', line 23 def close @connection.close end |
#create_channel ⇒ Object
39 40 41 |
# File 'lib/jack_rabbit/connection.rb', line 39 def create_channel @connection.create_channel end |
#open ⇒ Object
18 19 20 21 |
# File 'lib/jack_rabbit/connection.rb', line 18 def open open_connection(@uri, @options) self end |
#reopen(reason) ⇒ Object
33 34 35 36 37 |
# File 'lib/jack_rabbit/connection.rb', line 33 def reopen(reason) debug('%s, reconnecting...' % reason.inspect) open_connection(@uri, @options) @channels.each { |channel| channel.reopen } end |