Skip to content

Commit

Permalink
Use message_length_limit to unify parameter name between plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
repeatedly committed Mar 22, 2017
1 parent 881d481 commit a1a9fe4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/fluent/plugin/in_udp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ class UdpInput < Input
desc "The field name of the client's hostname."
config_param :source_hostname_key, :string, default: nil

config_param :body_size_limit, :size, default: 4096
desc "Deprecated parameter. Use message_length_limit instead"
config_param :body_size_limit, :size, default: nil, deprecated: "use message_length_limit instead."
desc "The max bytes of message"
config_param :message_length_limit, :size, default: 4096

config_param :blocking_timeout, :time, default: 0.5

Expand All @@ -43,6 +46,7 @@ def configure(conf)
super
@_event_loop_blocking_timeout = @blocking_timeout
@source_hostname_key ||= @source_host_key if @source_host_key
@message_length_limit = @body_size_limit if @body_size_limit

@parser = parser_create
end
Expand All @@ -55,7 +59,7 @@ def start
super

log.info "listening udp socket", bind: @bind, port: @port
server_create(:in_udp_server, @port, proto: :udp, bind: @bind, max_bytes: @body_size_limit) do |data, sock|
server_create(:in_udp_server, @port, proto: :udp, bind: @bind, max_bytes: @message_length_limit) do |data, sock|
data.chomp!
begin
@parser.parse(data) do |time, record|
Expand Down
12 changes: 11 additions & 1 deletion test/plugin/test_in_udp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def create_udp_socket(host, port)
d = create_driver(conf)
assert_equal PORT, d.instance.port
assert_equal bind, d.instance.bind
assert_equal 4096, d.instance.body_size_limit
assert_equal 4096, d.instance.message_length_limit
end

data(
Expand Down Expand Up @@ -86,6 +86,16 @@ def create_udp_socket(host, port)
end
end

data(
'message_length_limit' => 'message_length_limit 2048',
'body_size_limit' => 'body_size_limit 2048'
)
test 'message_length_limit/body_size_limit compatibility' do |param|

d = create_driver(CONFIG + param)
assert_equal 2048, d.instance.message_length_limit
end

data(
'none' => {
'format' => 'none',
Expand Down

0 comments on commit a1a9fe4

Please sign in to comment.