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.
6 7 8 |
# File 'lib/kafka/protocol/message_set.rb', line 6 def initialize(messages: []) @messages = end |
Instance Attribute Details
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
4 5 6 |
# File 'lib/kafka/protocol/message_set.rb', line 4 def @messages end |
Class Method Details
.decode(decoder) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/kafka/protocol/message_set.rb', line 26 def self.decode(decoder) = [] until decoder.eof? begin = Message.decode(decoder) if .compressed? = .decompress .concat(.) 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
14 15 16 |
# File 'lib/kafka/protocol/message_set.rb', line 14 def ==(other) == other. end |
#encode(encoder) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/kafka/protocol/message_set.rb', line 18 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
10 11 12 |
# File 'lib/kafka/protocol/message_set.rb', line 10 def size @messages.size end |