Skip to content

Commit

Permalink
in_syslog: add receive_buffer_size parameter in transport
Browse files Browse the repository at this point in the history
Signed-off-by: Shizuo Fujita <[email protected]>
  • Loading branch information
Watson1978 committed Sep 27, 2024
1 parent 7e39526 commit 756e854
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/fluent/plugin/in_syslog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ class SyslogInput < Input
# overwrite server plugin to change default to :udp
config_section :transport, required: false, multi: false, init: true, param_name: :transport_config do
config_argument :protocol, :enum, list: [:tcp, :udp, :tls], default: :udp
desc "The max size of socket receive buffer. SO_RCVBUF"
config_param :receive_buffer_size, :size, default: nil
end

def configure(conf)
Expand Down Expand Up @@ -170,7 +172,7 @@ def start
end

def start_udp_server
server_create_udp(:in_syslog_udp_server, @port, bind: @bind, max_bytes: @message_length_limit, resolve_name: @resolve_hostname) do |data, sock|
server_create_udp(:in_syslog_udp_server, @port, bind: @bind, max_bytes: @message_length_limit, resolve_name: @resolve_hostname, receive_buffer_size: @transport_config.receive_buffer_size) do |data, sock|
message_handler(data.chomp, sock)
end
end
Expand Down
8 changes: 8 additions & 0 deletions test/plugin/test_in_syslog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ def test_respect_protocol_type_than_transport
compare_test_result(d.events, tests)
end

data('Default receive_buffer_size' => ["<transport udp>\n </transport>", nil],
'Use receive_buffer_size' => ["<transport udp>\n receive_buffer_size 1234567\n </transport>", 1234567],)
def test_transport_receive_buffer_size(param)
conf, expected = *param
d = create_driver([ipv4_config, conf].join("\n"))

assert_equal(expected, d.instance.transport_config.receive_buffer_size)
end

data(
ipv4: ['127.0.0.1', :ipv4, ::Socket::AF_INET],
Expand Down

0 comments on commit 756e854

Please sign in to comment.