Class: Basquiat::Adapters::RabbitMq::Connection
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Basquiat::Adapters::RabbitMq::Connection
- Defined in:
- lib/basquiat/adapters/rabbitmq/connection.rb
Overview
Control the connection to the RabitMQ server. Delegates calls to Bunny::Connection
Instance Method Summary collapse
-
#connected? ⇒ Boolean
checks if the connection is started.
-
#create_channel ⇒ Bunny::Channel
Creates a channel.
-
#disconnect ⇒ Object
Closes all channels and then the connection.
-
#initialize(hosts:, port: 5672, failover: {}, auth: {}) ⇒ Connection
constructor
A new instance of Connection.
-
#start ⇒ Object
Starts the connection if needed.
Constructor Details
#initialize(hosts:, port: 5672, failover: {}, auth: {}) ⇒ Connection
Returns a new instance of Connection.
18 19 20 21 22 23 |
# File 'lib/basquiat/adapters/rabbitmq/connection.rb', line 18 def initialize(hosts:, port: 5672, failover: {}, auth: {}) @hosts = hosts @port = port @failover = failover @auth = auth end |
Instance Method Details
#connected? ⇒ Boolean
checks if the connection is started
40 41 42 |
# File 'lib/basquiat/adapters/rabbitmq/connection.rb', line 40 def connected? connection.status == :started end |
#create_channel ⇒ Bunny::Channel
Creates a channel
27 28 29 30 31 |
# File 'lib/basquiat/adapters/rabbitmq/connection.rb', line 27 def create_channel connection.start unless connected? Basquiat.logger.debug 'Creating a new channel' connection.create_channel end |
#disconnect ⇒ Object
Closes all channels and then the connection.
45 46 47 48 49 |
# File 'lib/basquiat/adapters/rabbitmq/connection.rb', line 45 def disconnect connection.close_all_channels connection.close reset end |