From cacc2c732d4eaab646ace81dfb15af1f8a149e7b Mon Sep 17 00:00:00 2001 From: Pranjal Gupta Date: Fri, 22 Oct 2021 15:19:40 +0530 Subject: [PATCH] in_tail_with_throttle: Remove nested method and modify indentation Signed-off-by: Pranjal Gupta --- lib/fluent/plugin/in_tail_with_throttle.rb | 22 +++++++++++----------- test/plugin/test_in_tail_with_throttle.rb | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/fluent/plugin/in_tail_with_throttle.rb b/lib/fluent/plugin/in_tail_with_throttle.rb index b297916222..4772cfd287 100644 --- a/lib/fluent/plugin/in_tail_with_throttle.rb +++ b/lib/fluent/plugin/in_tail_with_throttle.rb @@ -83,17 +83,17 @@ def construct_groupwatchers end end - def find_group_from_metadata(path) - def find_group(namespace, appname) - namespace_key = @group_watchers.keys.find { |regexp| namespace.match?(regexp) && regexp != DEFAULT_NAMESPACE } - namespace_key ||= DEFAULT_NAMESPACE + def find_group(namespace, appname) + namespace_key = @group_watchers.keys.find { |regexp| namespace.match?(regexp) && regexp != DEFAULT_NAMESPACE } + namespace_key ||= DEFAULT_NAMESPACE - appname_key = @group_watchers[namespace_key].keys.find { |regexp| appname.match?(regexp) && regexp != DEFAULT_APPNAME } - appname_key ||= DEFAULT_APPNAME + appname_key = @group_watchers[namespace_key].keys.find { |regexp| appname.match?(regexp) && regexp != DEFAULT_APPNAME } + appname_key ||= DEFAULT_APPNAME - @group_watchers[namespace_key][appname_key] - end - + @group_watchers[namespace_key][appname_key] + end + + def find_group_from_metadata(path) begin metadata = @group.pattern.match(path) group_watcher = find_group(metadata['namespace'], metadata['appname']) @@ -120,8 +120,8 @@ def setup_watcher(target_info, pe) tw.group_watcher = group_watcher tw - rescue => e - raise e + rescue => e + raise e end def detach_watcher_after_rotate_wait(tw, ino) diff --git a/test/plugin/test_in_tail_with_throttle.rb b/test/plugin/test_in_tail_with_throttle.rb index e2420a17dd..daaa4c9161 100644 --- a/test/plugin/test_in_tail_with_throttle.rb +++ b/test/plugin/test_in_tail_with_throttle.rb @@ -1,5 +1,5 @@ require_relative '../helper' -# require_relative './test_in_tail' + require 'fluent/test' require 'fluent/test/helpers' require 'fluent/test/driver/input'