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.



55
56
57
58
59
# File 'lib/fluent/plugin/buf_event_limited.rb', line 55

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.



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

def limit
  @limit
end

#record_countObject (readonly)

Returns the value of attribute record_count.



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

def record_count
  @record_count
end

Instance Method Details

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



61
62
63
64
# File 'lib/fluent/plugin/buf_event_limited.rb', line 61

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

#full?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/fluent/plugin/buf_event_limited.rb', line 71

def full?
  record_count >= limit
end

#remaining_capacityObject



67
68
69
# File 'lib/fluent/plugin/buf_event_limited.rb', line 67

def remaining_capacity
  @limit - record_count
end