View Source KafkaEx.Cluster.PartitionInfo (kafka_ex v1.0.0-rc.1)

Information about a topic partition.

Contains metadata about a specific partition including its leader broker, replica assignments, and in-sync replica (ISR) list.

Java equivalent: org.apache.kafka.common.PartitionInfo

Summary

Functions

Builds a PartitionInfo struct from keyword options.

Builds a PartitionInfo struct from partition metadata response.

Returns the list of in-sync replica node IDs.

Returns the leader node ID.

Returns the partition number.

Returns the list of replica node IDs.

Types

@type t() :: %KafkaEx.Cluster.PartitionInfo{
  isr: [integer()],
  leader: integer(),
  partition_id: integer(),
  replicas: [integer()]
}

Functions

@spec build(Keyword.t()) :: t()

Builds a PartitionInfo struct from keyword options.

Options

  • :partition_id - (required) The partition number
  • :leader - The leader node ID (default: -1)
  • :replicas - List of replica node IDs (default: [])
  • :isr - List of in-sync replica node IDs (default: [])
Link to this function

from_partition_metadata(map)

View Source
@spec from_partition_metadata(map()) :: t()

Builds a PartitionInfo struct from partition metadata response.

Parameters

The metadata map should contain:

  • :error_code - Must be 0 for successful parsing
  • :partition - The partition number
  • :leader - The leader node ID
  • :replicas - List of replica node IDs
  • :isr - List of in-sync replica node IDs
Link to this function

in_sync_replicas(partition_info)

View Source
@spec in_sync_replicas(t()) :: [integer()]

Returns the list of in-sync replica node IDs.

Provided for API compatibility with Java's PartitionInfo.inSyncReplicas().

@spec leader(t()) :: integer()

Returns the leader node ID.

Provided for API compatibility with Java's PartitionInfo.leader(). Returns -1 if no leader is available.

Link to this function

partition(partition_info)

View Source
@spec partition(t()) :: integer()

Returns the partition number.

Provided for API compatibility with Java's PartitionInfo.partition().

Link to this function

replicas(partition_info)

View Source
@spec replicas(t()) :: [integer()]

Returns the list of replica node IDs.

Provided for API compatibility with Java's PartitionInfo.replicas().