Class: Kafka::FFI::PartitionMetadata

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/kafka/ffi/partition_metadata.rb

Instance Method Summary collapse

Instance Method Details

#errornil, Kafka::ResponseError

Returns the error for the Partition as reported by the Broker.

Returns:



26
27
28
29
30
# File 'lib/kafka/ffi/partition_metadata.rb', line 26

def error
  if self[:err] != :ok
    return ::Kafka::ResponseError.new(self[:err])
  end
end

#idInteger

Returns the Partition’s ID

Returns:

  • (Integer)

    Partition ID



18
19
20
# File 'lib/kafka/ffi/partition_metadata.rb', line 18

def id
  self[:id]
end

#in_sync_replicasArray<Integer>

Returns the Broker IDs of the in-sync replicas for this Partition.

Returns:

  • (Array<Integer>)

    IDs of Brokers that have in-sync replicas.



53
54
55
56
57
58
59
# File 'lib/kafka/ffi/partition_metadata.rb', line 53

def in_sync_replicas
  if self[:isr_cnt] == 0 || self[:isrs].null?
    return []
  end

  self[:isrs].read_array_of_int32(self[:isr_cnt])
end

#leaderInteger

ID of the Leader Broker for this Partition

Returns:

  • (Integer)

    Leader Broker ID



35
36
37
# File 'lib/kafka/ffi/partition_metadata.rb', line 35

def leader
  self[:leader]
end

#replicasArray<Integer>

Returns the Broker IDs of the Brokers with replicas of this Partition.

Returns:

  • (Array<Integer>)

    IDs for Brokers with replicas



42
43
44
45
46
47
48
# File 'lib/kafka/ffi/partition_metadata.rb', line 42

def replicas
  if self[:replica_cnt] == 0 || self[:replicas].null?
    return []
  end

  self[:replicas].read_array_of_int32(self[:replica_cnt])
end