Class: Peatio::MQ::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/peatio/mq/client.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.channelObject

Returns the value of attribute channel.



4
5
6
# File 'lib/peatio/mq/client.rb', line 4

def channel
  @channel
end

.connectionObject

Returns the value of attribute connection.



4
5
6
# File 'lib/peatio/mq/client.rb', line 4

def connection
  @connection
end

Class Method Details

.connect!Object



15
16
17
18
# File 'lib/peatio/mq/client.rb', line 15

def connect!
  @connection = Bunny.new(@options)
  @connection.start
end

.create_channel!Object



20
21
22
# File 'lib/peatio/mq/client.rb', line 20

def create_channel!
  @channel = @connection.create_channel
end

.disconnectObject



24
25
26
27
# File 'lib/peatio/mq/client.rb', line 24

def disconnect
  @connection.close
  yield if block_given?
end

.newObject



6
7
8
9
10
11
12
13
# File 'lib/peatio/mq/client.rb', line 6

def new
  @options = {
    host: ENV["RABBITMQ_HOST"] || "0.0.0.0",
    port: ENV["RABBITMQ_PORT"] || "5672",
    username: ENV["RABBITMQ_USER"],
    password: ENV["RABBITMQ_PASSWORD"],
  }
end