logstash/lib/net/server.rb
Jordan Sissel 42df5ba36b - Support yielding to blocks for client and server #run methods
- Start hacking on having client writes block if we are far behind on getting
  message acks (w/ exponential backoff).
2009-08-18 09:45:02 +00:00

28 lines
665 B
Ruby

require 'rubygems'
require 'eventmachine'
require 'lib/net/socket'
module LogStash; module Net
# The MessageServer class exists only as an alias
# to the MessageSocketMux. You should use the
# client class if you are implementing a client.
class MessageServer
def initialize(host, port)
@host = host
@port = port
end
def run
EventMachine.run do
listen(@host, @port)
yield self if block_given?
end
end
def listen(host, port)
EventMachine::start_server(host, port, MessageSocket) do |m|
m.handler = self
end
end
end # class MessageServer
end; end # module LogStash::Net