class Liebre::Bridge
Constants
- NotStarted
Attributes
config[R]
started[W]
Public Class Methods
new(config)
click to toggle source
# File lib/liebre/bridge.rb, line 9 def initialize config @config = config @started = false end
Public Instance Methods
open_channel(opts)
click to toggle source
# File lib/liebre/bridge.rb, line 29 def open_channel opts if started? builder = ChannelBuilder.new(connections, opts) builder.call else raise NotStarted end end
start()
click to toggle source
# File lib/liebre/bridge.rb, line 18 def start if not started? connections.each do |name, conn| conn.start logger.info("Connection started: #{name.inspect}") end self.started = true end end
started?()
click to toggle source
# File lib/liebre/bridge.rb, line 14 def started? @started end
stop()
click to toggle source
# File lib/liebre/bridge.rb, line 38 def stop if started? connections.each { |_name, conn| conn.stop } self.started = false end end
Private Instance Methods
adapter()
click to toggle source
# File lib/liebre/bridge.rb, line 60 def adapter config.adapter end
conn_configs()
click to toggle source
# File lib/liebre/bridge.rb, line 64 def conn_configs config.connections end
connections()
click to toggle source
# File lib/liebre/bridge.rb, line 48 def connections @connections ||= conn_configs.reduce({}) do |all, (name, opts)| connection = adapter.connection(opts) all.merge!(name => connection) end end
logger()
click to toggle source
# File lib/liebre/bridge.rb, line 56 def logger config.logger end