Class: Fluent::EventLimitedBufferChunk

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, path, unique_id, limit, mode = "a+") ⇒ EventLimitedBufferChunk

Returns a new instance of EventLimitedBufferChunk.



37
38
39
40
41
# File 'lib/fluent/plugin/buf_event_limited.rb', line 37

def initialize(key, path, unique_id, limit, mode = "a+")
  super(key, path, unique_id, mode = "a+")
  @limit = limit
  @record_count = MessagePackFormattedBufferData.new(read).size
end

Instance Attribute Details

#limitObject (readonly)

Returns the value of attribute limit.



35
36
37
# File 'lib/fluent/plugin/buf_event_limited.rb', line 35

def limit
  @limit
end

#record_countObject (readonly)

Returns the value of attribute record_count.



35
36
37
# File 'lib/fluent/plugin/buf_event_limited.rb', line 35

def record_count
  @record_count
end

Instance Method Details

#<<(data, record_count) ⇒ Object Also known as: write



43
44
45
46
# File 'lib/fluent/plugin/buf_event_limited.rb', line 43

def <<(data, record_count)
  super(data)
  @record_count += record_count
end

#full?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/fluent/plugin/buf_event_limited.rb', line 53

def full?
  record_count >= limit
end

#remaining_capacityObject



49
50
51
# File 'lib/fluent/plugin/buf_event_limited.rb', line 49

def remaining_capacity
  @limit - record_count
end