Class: Kafka::Protocol::MessageSet
- Inherits:
-
Object
- Object
- Kafka::Protocol::MessageSet
- Defined in:
- lib/kafka/protocol/message_set.rb
Instance Attribute Summary collapse
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #encode(encoder) ⇒ Object
-
#initialize(messages: []) ⇒ MessageSet
constructor
A new instance of MessageSet.
- #size ⇒ Object
Constructor Details
#initialize(messages: []) ⇒ MessageSet
Returns a new instance of MessageSet.
8 9 10 |
# File 'lib/kafka/protocol/message_set.rb', line 8 def initialize(messages: []) @messages = end |
Instance Attribute Details
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
6 7 8 |
# File 'lib/kafka/protocol/message_set.rb', line 6 def @messages end |
Class Method Details
.decode(decoder) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/kafka/protocol/message_set.rb', line 28 def self.decode(decoder) = [] until decoder.eof? begin = Message.decode(decoder) if .compressed? .concat(.decompress) else << end rescue EOFError if .empty? # If the first message in the set is truncated, it's likely because the # message is larger than the maximum size that we have asked for. raise MessageTooLargeToRead else # We tried to decode a partial message at the end of the set; just skip it. end end end new(messages: ) end |
Instance Method Details
#==(other) ⇒ Object
16 17 18 |
# File 'lib/kafka/protocol/message_set.rb', line 16 def ==(other) == other. end |
#encode(encoder) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/kafka/protocol/message_set.rb', line 20 def encode(encoder) # Messages in a message set are *not* encoded as an array. Rather, # they are written in sequence. @messages.each do || .encode(encoder) end end |
#size ⇒ Object
12 13 14 |
# File 'lib/kafka/protocol/message_set.rb', line 12 def size @messages.size end |