class Sheltie::Client

Constants

VERSION

Public Class Methods

connect(opts) click to toggle source
# File lib/sheltie/client.rb, line 38
def self.connect(opts)
  @@connection ||= Sheltie::Client.new(opts)
  true
end
connection() click to toggle source
# File lib/sheltie/client.rb, line 34
def self.connection
  @@connection
end
new(opts) click to toggle source
# File lib/sheltie/client.rb, line 10
def initialize(opts)
  @conn = Bunny.new(opts)
  @conn.start
  @conn
end
publish(agent, metric, value, registered_at=Time.now.to_i) click to toggle source
# File lib/sheltie/client.rb, line 16
def self.publish(agent, metric, value, registered_at=Time.now.to_i)
  if Sheltie::Client.connection
    Sheltie::Client.connection.queue.publish({agent: agent, metric: metric, value: value, registered_at: registered_at}.to_json, :routing_key => Sheltie::Client.connection.queue.name, :persistent => true)
    true
  else
    false
  end
end

Public Instance Methods

queue() click to toggle source
# File lib/sheltie/client.rb, line 25
def queue
  if !@q
    ch = @conn.create_channel
    @q  = ch.queue("sheltie.metrics", :durable => true)
    x  = ch.default_exchange
  end
  @q
end