class Fluent::Plugin::OutSyslogRFC5424
Constants
- DEFAULT_FORMATTER
Public Instance Methods
close()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_syslog_rfc5424.rb, line 41 def close super @sockets.each_value { |s| s.close } @sockets = {} end
configure(config)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_syslog_rfc5424.rb, line 20 def configure(config) super @sockets = {} @formatter = formatter_create end
write(chunk)
click to toggle source
# File lib/fluent/plugin/out_syslog_rfc5424.rb, line 26 def write(chunk) socket = find_or_create_socket(@transport.to_sym, @host, @port) tag = chunk.metadata.tag chunk.each do |time, record| begin socket.write_nonblock @formatter.format(tag, time, record) IO.select(nil, [socket], nil, 1) || raise(StandardError.new "ReconnectError") rescue => e @sockets.delete(socket_key(@transport.to_sym, @host, @port)) socket.close raise end end end
Private Instance Methods
find_or_create_socket(transport, host, port)
click to toggle source
# File lib/fluent/plugin/out_syslog_rfc5424.rb, line 49 def find_or_create_socket(transport, host, port) socket = find_socket(transport, host, port) return socket if socket @sockets[socket_key(transport, host, port)] = socket_create(transport.to_sym, host, port, socket_options) end
find_socket(transport, host, port)
click to toggle source
# File lib/fluent/plugin/out_syslog_rfc5424.rb, line 67 def find_socket(transport, host, port) @sockets[socket_key(transport, host, port)] end
socket_key(transport, host, port)
click to toggle source
# File lib/fluent/plugin/out_syslog_rfc5424.rb, line 63 def socket_key(transport, host, port) "#{host}:#{port}:#{transport}" end
socket_options()
click to toggle source
# File lib/fluent/plugin/out_syslog_rfc5424.rb, line 56 def socket_options return {} unless @transport == 'tls' # TODO: make timeouts configurable { insecure: @insecure, verify_fqdn: !@insecure, cert_paths: @trusted_ca_path } #, connect_timeout: 1, send_timeout: 1, recv_timeout: 1, linger_timeout: 1 } end