Coolio::Socket
# File lib/fluent/plugin/socket_util.rb, line 53 def initialize(io, log, delimiter, callback) super(io) if io.is_a?(TCPSocket) @addr = (io.peeraddr rescue PEERADDR_FAILED) opt = [1, @timeout.to_i].pack('I!I!') # { int l_onoff; int l_linger; } io.setsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER, opt) end @delimiter = delimiter @callback = callback @log = log @log.trace { "accepted fluent socket object_id=#{self.object_id}" } @buffer = "".force_encoding('ASCII-8BIT') end
# File lib/fluent/plugin/socket_util.rb, line 86 def on_close @log.trace { "closed fluent socket object_id=#{self.object_id}" } end
# File lib/fluent/plugin/socket_util.rb, line 68 def on_connect end
# File lib/fluent/plugin/socket_util.rb, line 71 def on_read(data) @buffer << data pos = 0 while i = @buffer.index(@delimiter, pos) msg = @buffer[pos...i] @callback.call(msg, @addr) pos = i + @delimiter.length end @buffer.slice!(0, pos) if pos > 0 rescue => e @log.error "unexpected error", :error => e, :error_class => e.class close end
Generated with the Darkfish Rdoc Generator 2.