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.
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
#limit ⇒ Object (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_count ⇒ Object (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
71 72 73 |
# File 'lib/fluent/plugin/buf_event_limited.rb', line 71 def full? record_count >= limit end |
#remaining_capacity ⇒ Object
67 68 69 |
# File 'lib/fluent/plugin/buf_event_limited.rb', line 67 def remaining_capacity @limit - record_count end |