Class: MultipleMan::Connection
- Inherits:
-
Object
- Object
- MultipleMan::Connection
- Defined in:
- lib/multiple_man/connection.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(channel) ⇒ Connection
constructor
A new instance of Connection.
- #topic ⇒ Object
- #topic_name ⇒ Object
Constructor Details
#initialize(channel) ⇒ Connection
Returns a new instance of Connection.
25 26 27 |
# File 'lib/multiple_man/connection.rb', line 25 def initialize(channel) self.channel = channel end |
Class Method Details
.channel_pool ⇒ Object
15 16 17 |
# File 'lib/multiple_man/connection.rb', line 15 def self.channel_pool @channel_pool ||= ConnectionPool.new(size: 25, timeout: 5) { connection.create_channel } end |
.connect ⇒ Object
19 20 21 22 23 |
# File 'lib/multiple_man/connection.rb', line 19 def self.connect channel_pool.with do |channel| yield new(channel) if block_given? end end |
.connection ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/multiple_man/connection.rb', line 6 def self.connection @connection ||= begin connection = Bunny.new(MultipleMan.configuration.connection) MultipleMan.logger.info "Connecting to #{MultipleMan.configuration.connection}" connection.start connection end end |
Instance Method Details
#topic ⇒ Object
29 30 31 |
# File 'lib/multiple_man/connection.rb', line 29 def topic @topic ||= channel.topic(topic_name) end |
#topic_name ⇒ Object
33 34 35 |
# File 'lib/multiple_man/connection.rb', line 33 def topic_name MultipleMan.configuration.topic_name end |