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 committed Mar 24, 2017
1 parent d8df66c commit e903b02
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/fluent/plugin/in_syslog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ def initialize
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

def configure(conf)
super
Expand Down
14 changes: 12 additions & 2 deletions lib/fluent/plugin/in_udp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,23 @@ class UdpInput < SocketUtil::BaseInput
Plugin.register_input('udp', self)

config_set_default :port, 5160
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

def configure(conf)
super

@message_length_limit = @body_size_limit if @body_size_limit
end

def listen(callback)
log.info "listening udp socket on #{@bind}:#{@port}"
@usock = SocketUtil.create_udp_socket(@bind)
@usock.bind(@bind, @port)
SocketUtil::UdpHandler.new(@usock, log, @body_size_limit, callback)
SocketUtil::UdpHandler.new(@usock, log, @message_length_limit, callback)
end
end
end
11 changes: 10 additions & 1 deletion test/plugin/test_in_udp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,19 @@ def test_configure
d = create_driver(v)
assert_equal PORT, d.instance.port
assert_equal k, d.instance.bind
assert_equal 4096, d.instance.body_size_limit
assert_equal 4096, d.instance.message_length_limit
}
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

def test_time_format
configs = {'127.0.0.1' => CONFIG}
configs.merge!('::1' => IPv6_CONFIG) if ipv6_enabled?
Expand Down

0 comments on commit e903b02

Please sign in to comment.