Class: ConfigParser::Quota

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/plugin/config_parser.rb

Overview

Quota class represents a single quota configuration Attributes:

+name+: (String) The name of the quota.
+desc+: (String) A description of the quota.
+group_by+: (Array of Arrays of Strings) Specifies how to group transactions or events for quota tracking.
+match_by+: (Hash) Defines the conditions that must be met for the quota to apply. Keys are the conditions to match, and values are the expected values.
+bucket_size+: (Integer) The size of the quota bucket, indicating how many transactions or events can occur before the quota is exceeded. A value of -1 indicates no quota limit.
+duration+: (Integer) The duration (in seconds) for which the quota bucket size is valid.
+action+: (String) The action to take when the quota is reached. Must be one of the predefined actions in @@allowed_actions.

Constant Summary collapse

@@allowed_actions =
Set["drop", "reemit"]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, desc, group_by, match_by, bucket_size, duration, action) ⇒ Quota

Returns a new instance of Quota.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fluent/plugin/config_parser.rb', line 23

def initialize(name, desc, group_by, match_by, bucket_size, duration, action)
  raise "Name cannot be empty" if name.nil?
  raise "Group by cannot be empty" if group_by.nil?
  raise "Bucket size cannot be empty" unless bucket_size.is_a?(Integer)
  raise "Duration must be time delta (eg. 2s, 4m)" if duration.nil? || !duration.is_a?(String) || duration.strip.empty?
  raise "Action must be one of #{@@allowed_actions}" unless @@allowed_actions.include?action
  @name = name
  @desc = desc
  @group_by = group_by
  @match_by = match_by
  @bucket_size = bucket_size
  @duration = Fluent::Config.time_value(duration)
  @action = action
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



19
20
21
# File 'lib/fluent/plugin/config_parser.rb', line 19

def action
  @action
end

#bucket_sizeObject (readonly)

Returns the value of attribute bucket_size.



19
20
21
# File 'lib/fluent/plugin/config_parser.rb', line 19

def bucket_size
  @bucket_size
end

#descObject (readonly)

Returns the value of attribute desc.



19
20
21
# File 'lib/fluent/plugin/config_parser.rb', line 19

def desc
  @desc
end

#durationObject (readonly)

Returns the value of attribute duration.



19
20
21
# File 'lib/fluent/plugin/config_parser.rb', line 19

def duration
  @duration
end

#group_byObject (readonly)

Returns the value of attribute group_by.



19
20
21
# File 'lib/fluent/plugin/config_parser.rb', line 19

def group_by
  @group_by
end

#match_byObject (readonly)

Returns the value of attribute match_by.



19
20
21
# File 'lib/fluent/plugin/config_parser.rb', line 19

def match_by
  @match_by
end

#nameObject (readonly)

Returns the value of attribute name.



19
20
21
# File 'lib/fluent/plugin/config_parser.rb', line 19

def name
  @name
end