mirror of
https://github.com/ditkrg/outboxable.git
synced 2026-01-22 22:06:47 +00:00
Adds singleton connection class
This commit is contained in:
parent
ea688be970
commit
4c840bdff0
26
lib/outboxable/connection.rb
Normal file
26
lib/outboxable/connection.rb
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
require 'singleton'
|
||||||
|
|
||||||
|
module Outboxable
|
||||||
|
class Connection
|
||||||
|
include ::Singleton
|
||||||
|
attr_reader :connection
|
||||||
|
|
||||||
|
def initialize
|
||||||
|
@connection = Bunny.new(
|
||||||
|
host: RabbitCarrots.configuration.rabbitmq_host,
|
||||||
|
port: RabbitCarrots.configuration.rabbitmq_port,
|
||||||
|
user: RabbitCarrots.configuration.rabbitmq_user,
|
||||||
|
password: RabbitCarrots.configuration.rabbitmq_password,
|
||||||
|
vhost: RabbitCarrots.configuration.rabbitmq_vhost
|
||||||
|
)
|
||||||
|
|
||||||
|
@connection.start
|
||||||
|
end
|
||||||
|
|
||||||
|
def channel
|
||||||
|
@channel ||= ConnectionPool.new do
|
||||||
|
connection.create_channel
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in New Issue
Block a user