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
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"
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).
@spec has_socket?(t(), KafkaEx.Network.Socket.t()) :: boolean()
Checks if the broker's socket matches the given socket.
@spec put_socket(t(), KafkaEx.Network.Socket.t() | nil) :: t()
Updates the broker's socket.
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)"