Class: KafkaSyrup::Protocol::MetadataResponse
- Defined in:
- lib/kafka_syrup/protocol/metadata_response.rb
Defined Under Namespace
Classes: Broker, Partition, Topic
Instance Attribute Summary collapse
-
#brokers ⇒ Object
Returns the value of attribute brokers.
-
#topics ⇒ Object
Returns the value of attribute topics.
Attributes inherited from Response
Instance Method Summary collapse
- #add_broker(node, host, port) ⇒ Object
- #add_topic(code, name) ⇒ Object
- #decode(io) ⇒ Object
- #defaults ⇒ Object
- #encode ⇒ Object
Methods inherited from Base
Methods included from Utils
Constructor Details
This class inherits a constructor from KafkaSyrup::Protocol::Base
Instance Attribute Details
#brokers ⇒ Object
Returns the value of attribute brokers.
4 5 6 |
# File 'lib/kafka_syrup/protocol/metadata_response.rb', line 4 def brokers @brokers end |
#topics ⇒ Object
Returns the value of attribute topics.
4 5 6 |
# File 'lib/kafka_syrup/protocol/metadata_response.rb', line 4 def topics @topics end |
Instance Method Details
#add_broker(node, host, port) ⇒ Object
10 11 12 13 14 |
# File 'lib/kafka_syrup/protocol/metadata_response.rb', line 10 def add_broker(node, host, port) broker = Broker.new(node, host, port) brokers << broker broker end |
#add_topic(code, name) ⇒ Object
16 17 18 19 20 |
# File 'lib/kafka_syrup/protocol/metadata_response.rb', line 16 def add_topic(code, name) topic = Topic.new(code, name, []) topics << topic topic end |
#decode(io) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/kafka_syrup/protocol/metadata_response.rb', line 31 def decode(io) super self.brokers = E.read_array(io, &Broker.method(:decode)) self.topics = E.read_array(io, &Topic.method(:decode)) topics.map(&:code).each(&KafkaResponseErrors.method(:raise_from_code)) topics.flat_map(&:partitions).map(&:code).each(&KafkaResponseErrors.method(:raise_from_code)) end |
#defaults ⇒ Object
6 7 8 |
# File 'lib/kafka_syrup/protocol/metadata_response.rb', line 6 def defaults { brokers: [], topics: [] } end |