Class: JackRabbit::Connection

Inherits:
Object
  • Object
show all
Includes:
Backoff, Logging
Defined in:
lib/jack_rabbit/connection.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{ connection_timeout: 5, heartbeat_interval: 5 }

Constants included from Logging

Logging::TAG

Constants included from Backoff

Backoff::MAX

Instance Method Summary collapse

Methods included from Logging

#set_logger

Methods included from Backoff

#with_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, options)
  @uri, @options = uri, options.merge(connection_options(uri))
  @channels = []
end

Instance Method Details

#channel(options) ⇒ Object



27
28
29
30
31
# File 'lib/jack_rabbit/connection.rb', line 27

def channel(options)
  channel = Channel.new(self, options)
  @channels << channel
  channel
end

#closeObject



23
24
25
# File 'lib/jack_rabbit/connection.rb', line 23

def close
  @connection.close
end

#create_channelObject



39
40
41
# File 'lib/jack_rabbit/connection.rb', line 39

def create_channel
  @connection.create_channel
end

#openObject



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