Class: Fluent::StreamOutput

Inherits:
BufferedOutput
  • Object
show all
Defined in:
lib/fluent/plugin/out_stream.rb

Overview

obsolete

Direct Known Subclasses

TcpOutput, UnixOutput

Defined Under Namespace

Classes: ReformatWriter

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



30
31
32
33
# File 'lib/fluent/plugin/out_stream.rb', line 30

def configure(conf)
  compat_parameters_convert(conf, :buffer)
  super
end

#flush_secondary(secondary) ⇒ Object



55
56
57
58
59
60
# File 'lib/fluent/plugin/out_stream.rb', line 55

def flush_secondary(secondary)
  unless secondary.is_a?(StreamOutput)
    secondary = ReformatWriter.new(secondary)
  end
  @buffer.pop(secondary)
end

#format_stream(tag, es) ⇒ Object



35
36
37
38
# File 'lib/fluent/plugin/out_stream.rb', line 35

def format_stream(tag, es)
  # use PackedForward
  [tag, es.to_msgpack_stream].to_msgpack
end

#write(chunk) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fluent/plugin/out_stream.rb', line 40

def write(chunk)
  sock = connect
  begin
    opt = [1, @send_timeout.to_i].pack('I!I!')  # { int l_onoff; int l_linger; }
    sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER, opt)

    opt = [@send_timeout.to_i, 0].pack('L!L!')  # struct timeval
    sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDTIMEO, opt)

    chunk.write_to(sock)
  ensure
    sock.close
  end
end