Class: Kanina::Server

Inherits:
Object
  • Object
show all
Extended by:
Logger
Defined in:
lib/kanina/server.rb

Overview

Kanina::Server loads configuration, opens a connection to RabbitMQ and opens a channel so messages can be received and sent. This class is automatically called and handled by a Railtie, so you shouldn't have to invoke it by hand.

Constant Summary

Constants included from Logger

Logger::DEFAULT_LOG_LEVEL

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Logger

logger, say

Class Attribute Details

.channelObject (readonly)

Returns the value of attribute channel.



10
11
12
# File 'lib/kanina/server.rb', line 10

def channel
  @channel
end

.configObject

Returns the value of attribute config.



11
12
13
# File 'lib/kanina/server.rb', line 11

def config
  @config
end

.connectionObject (readonly)

Returns the value of attribute connection.



10
11
12
# File 'lib/kanina/server.rb', line 10

def connection
  @connection
end

.loudObject

Returns the value of attribute loud.



11
12
13
# File 'lib/kanina/server.rb', line 11

def loud
  @loud
end

Class Method Details

.startString

Loads the configuration, opens a connection, and opens the channel. This will automatically be run in the railtie when you install Kanina into a Rails project, so you shouldn't have to run it yourself.

Returns:

  • (String)

    status as 'started', unless something went wrong.



23
24
25
26
27
28
29
# File 'lib/kanina/server.rb', line 23

def start
  set_status 'starting'
  load_config unless @config.present?
  open_connection
  open_channel
  set_status 'started'
end

.statusString

Returns the current status of the server connection.

Returns:

  • (String)

    status, as 'off', 'starting', 'started', or 'stopping'



15
16
17
# File 'lib/kanina/server.rb', line 15

def status
  @status || 'off'
end

.stopString

Closes the connection to RabbitMQ.

Returns:

  • (String)

    status as 'stopping'



33
34
35
36
# File 'lib/kanina/server.rb', line 33

def stop
  set_status 'stopping'
  cleanup
end