Skip to content

Commit

Permalink
Merge pull request #1515 from fluent/unify-parameter-udp-and-syslog
Browse files Browse the repository at this point in the history
Unify parameter name between udp and syslog plugins
  • Loading branch information
repeatedly authored Mar 23, 2017
2 parents 881d481 + 1c2d5c7 commit 2b2c767
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
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

0 comments on commit 2b2c767

Please sign in to comment.