Class: KafkaSyrup::Protocol::MetadataResponse::Partition

Inherits:
Struct
  • Object
show all
Defined in:
lib/kafka_syrup/protocol/metadata_response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#codeObject

Returns the value of attribute code

Returns:

  • (Object)

    the current value of code



82
83
84
# File 'lib/kafka_syrup/protocol/metadata_response.rb', line 82

def code
  @code
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



82
83
84
# File 'lib/kafka_syrup/protocol/metadata_response.rb', line 82

def id
  @id
end

#isrObject

Returns the value of attribute isr

Returns:

  • (Object)

    the current value of isr



82
83
84
# File 'lib/kafka_syrup/protocol/metadata_response.rb', line 82

def isr
  @isr
end

#leaderObject

Returns the value of attribute leader

Returns:

  • (Object)

    the current value of leader



82
83
84
# File 'lib/kafka_syrup/protocol/metadata_response.rb', line 82

def leader
  @leader
end

#replicasObject

Returns the value of attribute replicas

Returns:

  • (Object)

    the current value of replicas



82
83
84
# File 'lib/kafka_syrup/protocol/metadata_response.rb', line 82

def replicas
  @replicas
end

Class Method Details

.decode(io) ⇒ Object



93
94
95
96
97
98
99
100
101
# File 'lib/kafka_syrup/protocol/metadata_response.rb', line 93

def self.decode(io)
  new(
    E.read_int16(io),                         # Error Code
    E.read_int32(io),                         # ID
    E.read_int32(io),                         # Leader
    E.read_array(io, &E.method(:read_int32)), # Replicas
    E.read_array(io, &E.method(:read_int32))  # ISR
  )
end

Instance Method Details

#encodeObject



83
84
85
86
87
88
89
90
91
# File 'lib/kafka_syrup/protocol/metadata_response.rb', line 83

def encode
  [
    E.write_int16(code),
    E.write_int32(id),
    E.write_int32(leader),
    E.write_array(replicas, &E.method(:write_int32)),
    E.write_array(isr, &E.method(:write_int32))
  ].join
end