class SheltieClient::Client
Public Class Methods
connect(opts)
click to toggle source
# File lib/sheltie_client.rb, line 38 def self.connect(opts) @@connection ||= SheltieClient::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 SheltieClient::Client.connection SheltieClient::Client.connection.queue.publish({agent: agent, metric: metric, value: value, registered_at: registered_at}.to_json, :routing_key => SheltieClient::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