Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify parameter name between udp and syslog plugins #1515

Merged
merged 2 commits into from
Mar 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/fluent/plugin/in_syslog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,16 @@ class SyslogInput < Input
config_param :source_hostname_key, :string, default: nil
desc 'The field name of source address of sender.'
config_param :source_address_key, :string, default: nil

desc 'The field name of the priority.'
config_param :priority_key, :string, default: nil
desc 'The field name of the facility.'
config_param :facility_key, :string, default: nil

config_param :blocking_timeout, :time, default: 0.5
desc "The max bytes of message"
config_param :message_length_limit, :size, default: 2048

config_param :blocking_timeout, :time, default: 0.5

config_section :parse do
config_set_default :@type, DEFAULT_PARSER
config_param :with_priority, :bool, default: true
Expand Down
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