Class: Fluent::Plugin::TcpOutput

Inherits:
Output
  • Object
show all
Defined in:
lib/fluent/plugin/out_tcp.rb

Instance Method Summary collapse

Instance Method Details

#try_write(chunk) ⇒ Object

omit configure, shutdown and other plugin API



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fluent/plugin/out_tcp.rb', line 15

def try_write(chunk)
  # 2. create socket
  socket = socket_create(:tcp, @host, @port)
  chunk.each do |time, record|
    # 3. write data to socket
    socket.write(record.to_json)
  end
ensure
  # 4. close socket
  socket.close if socket
end