class Slnky::Command::Response

Attributes

trace[R]

Public Class Methods

new(route, service) click to toggle source
# File lib/slnky/command/response.rb, line 6
def initialize(route, service)
  Slnky.config.service = service
  if route =~ /\:/
    (route, reply) = route.split(':', 2)
  end
  @route = route
  @reply = reply
  @service = Slnky::System.pid
  @started = false
  @exchange = nil
  @transport = nil
  @trace = []
end

Public Instance Methods

done!() click to toggle source
# File lib/slnky/command/response.rb, line 36
def done!
  pub :complete, "complete"
end
exchange=(exchange) click to toggle source
# File lib/slnky/command/response.rb, line 40
def exchange=(exchange)
  @exchange = exchange
end
output(message) click to toggle source
# File lib/slnky/command/response.rb, line 27
def output(message)
  info(message)
end
start!() click to toggle source
# File lib/slnky/command/response.rb, line 31
def start!
  pub :start, "start"
  @started = true
end

Private Instance Methods

config() click to toggle source
# File lib/slnky/command/response.rb, line 59
def config
  Slnky.config
end
exchange() click to toggle source
# File lib/slnky/command/response.rb, line 67
def exchange
  @exchange ||= transport.exchanges['response']
end
log() click to toggle source
# File lib/slnky/command/response.rb, line 63
def log
  Slnky.log
end
msg(level, message) click to toggle source
# File lib/slnky/command/response.rb, line 46
def msg(level, message)
  Slnky::Message.new({level: level, message: message, service: @service, reply: @reply})
end
pub(level, message) click to toggle source
# File lib/slnky/command/response.rb, line 50
def pub(level, message)
  # if @route.to_s =~ /^hipchat/
  #   chat(level, message)
  # else
    exchange.publish(msg(level, message), routing_key: @route)
  # end
  @trace << message
end
transport() click to toggle source
# File lib/slnky/command/response.rb, line 71
def transport
  @transport ||= Slnky::Transport.instance
end