Class: Rdkafka::Metadata::PartitionMetadata

Inherits:
CustomFFIStruct show all
Defined in:
lib/rdkafka/metadata.rb

Overview

FFI struct for rd_kafka_metadata_partition_t

Instance Method Summary collapse

Instance Method Details

#to_hHash{Symbol => Integer, Array<Integer>}

The base #to_h skips FFI pointer members, which would drop the replica and in-sync replica assignments entirely. We dereference those pointers here so the partition hash exposes the broker ids backing the partition (needed e.g. to plan replication changes).

Returns:

  • (Hash{Symbol => Integer, Array<Integer>})

    partition metadata:

    • :partition_id (Integer) - partition id
    • :leader (Integer) - broker id of the partition leader
    • :replica_count (Integer) - number of assigned replicas
    • :in_sync_replica_brokers (Integer) - number of in-sync replicas
    • :replicas (Array) - broker ids of the assigned replicas
    • :isrs (Array) - broker ids of the in-sync replicas


184
185
186
187
188
189
# File 'lib/rdkafka/metadata.rb', line 184

def to_h
  super.merge(
    replicas: read_broker_ids(self[:replicas], self[:replica_count]),
    isrs: read_broker_ids(self[:isrs], self[:in_sync_replica_brokers])
  )
end