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

Encapsulates what we know about a broker and our connection.

A broker represents a Kafka node in the cluster with its connection state.

Summary

Functions

Returns a human-readable address string for the broker.

Checks if the broker has an active socket connection. Returns true if the broker has a non-nil socket that is currently open, false otherwise.

Checks if the broker has a socket (connected or not).

Checks if the broker's socket matches the given socket.

Updates the broker's socket.

Returns a string identifying the broker with node_id and address.

Types

@type t() :: %KafkaEx.Cluster.Broker{
  host: binary(),
  node_id: non_neg_integer(),
  port: non_neg_integer(),
  rack: binary(),
  socket: KafkaEx.Network.Socket.t() | nil
}

Functions

@spec address(t()) :: String.t()

Returns a human-readable address string for the broker.

Examples

iex> broker = %KafkaEx.Cluster.Broker{host: "localhost", port: 9092, node_id: 1}
iex> KafkaEx.Cluster.Broker.address(broker)
"localhost:9092"
@spec connected?(t()) :: boolean()

Checks if the broker has an active socket connection. Returns true if the broker has a non-nil socket that is currently open, false otherwise.

@spec has_socket?(t()) :: boolean()

Checks if the broker has a socket (connected or not).

Link to this function

has_socket?(arg1, socket)

View Source
@spec has_socket?(t(), KafkaEx.Network.Socket.t()) :: boolean()

Checks if the broker's socket matches the given socket.

Link to this function

put_socket(broker, socket)

View Source
@spec put_socket(t(), KafkaEx.Network.Socket.t() | nil) :: t()

Updates the broker's socket.

@spec to_string(t()) :: String.t()

Returns a string identifying the broker with node_id and address.

Examples

iex> broker = %KafkaEx.Cluster.Broker{host: "localhost", port: 9092, node_id: 1}
iex> KafkaEx.Cluster.Broker.to_string(broker)
"broker 1 (localhost:9092)"