Class: Fluent::EventLimitedBufferChunk
- Inherits:
-
FileBufferChunk
- Object
- FileBufferChunk
- Fluent::EventLimitedBufferChunk
- Defined in:
- lib/fluent/plugin/buf_event_limited.rb
Instance Attribute Summary collapse
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#record_count ⇒ Object
readonly
Returns the value of attribute record_count.
Instance Method Summary collapse
- #<<(data, record_count) ⇒ Object (also: #write)
- #full? ⇒ Boolean
-
#initialize(key, path, unique_id, limit, mode = "a+") ⇒ EventLimitedBufferChunk
constructor
A new instance of EventLimitedBufferChunk.
- #remaining_capacity ⇒ Object
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
#limit ⇒ Object (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_count ⇒ Object (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
53 54 55 |
# File 'lib/fluent/plugin/buf_event_limited.rb', line 53 def full? record_count >= limit end |
#remaining_capacity ⇒ Object
49 50 51 |
# File 'lib/fluent/plugin/buf_event_limited.rb', line 49 def remaining_capacity @limit - record_count end |