Method: Fluent::Plugin::TailInput::GroupWatch#configure

Defined in:
lib/fluent/plugin/in_tail/group_watch.rb

#configure(conf) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/fluent/plugin/in_tail/group_watch.rb', line 60

def configure(conf)
  super

  unless @group.nil?
    ## Ensuring correct time period syntax
    @group.rule.each { |rule|
      raise "Metadata Group Limit >= DEFAULT_LIMIT" unless rule.limit >= GroupWatchParams::DEFAULT_LIMIT
    }

    @group_keys = Regexp.compile(@group.pattern).named_captures.keys
    @default_group_key = ([GroupWatchParams::DEFAULT_KEY] * @group_keys.length).join(GroupWatchParams::REGEXP_JOIN)

    ## Ensures that "specific" rules (with larger number of `rule.match` keys)
    ## have a higher priority against "generic" rules (with less number of `rule.match` keys).
    ## This will be helpful when a file satisfies more than one rule.
    @group.rule.sort_by! { |rule| -rule.match.length() }
    construct_groupwatchers
    @group_watchers[@default_group_key] ||= GroupWatcher.new(@group.rate_period, GroupWatchParams::DEFAULT_LIMIT)
  end
end