Class: Fluent::Plugin::TCPClientOutput

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTCPClientOutput

Returns a new instance of TCPClientOutput.



9
10
11
# File 'lib/fluent/plugin/out_tcp_client.rb', line 9

def initialize
  super
end

Instance Attribute Details

#formatterObject (readonly)

for testing



20
21
22
# File 'lib/fluent/plugin/out_tcp_client.rb', line 20

def formatter
  @formatter
end

Instance Method Details

#configure(conf) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/fluent/plugin/out_tcp_client.rb', line 22

def configure(conf)
  compat_parameters_convert(conf, :formatter)

  super

  @formatter = formatter_create
  @sock = nil
end

#format(tag, time, record) ⇒ Object



41
42
43
# File 'lib/fluent/plugin/out_tcp_client.rb', line 41

def format(tag, time, record)
  @formatter.format(tag, time, record)
end

#shutdownObject



36
37
38
39
# File 'lib/fluent/plugin/out_tcp_client.rb', line 36

def shutdown
  super
  disconnect
end

#startObject



31
32
33
34
# File 'lib/fluent/plugin/out_tcp_client.rb', line 31

def start
  super
  connect
end

#write(chunk) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/fluent/plugin/out_tcp_client.rb', line 45

def write(chunk)
  connect
  tries ||= 3

  chunk.write_to(@sock)
rescue => e
  if (tries -= 1) > 0
    reconnect
    retry
  else
    $log.warn("Failed writing data to socket: #{e}")
  end
end