class Nsqrb::Producer

Public Class Methods

new(host, port, topic) click to toggle source
# File lib/nsqrb/producer.rb, line 5
def initialize(host, port, topic)
  @http = ::Net::HTTP.new(host, port)
  @topic = topic
end

Public Instance Methods

post!(obj) click to toggle source
# File lib/nsqrb/producer.rb, line 10
def post!(obj)
  res = @http.post("/pub?topic=#{@topic}", obj.to_s)
  return if res.code == "200"
  res.error!
end