View Source Xandra.Cluster.Host (Xandra v0.20.0)

The data structure to represent a host in a Cassandra cluster.

The fields of this struct are public. See t/0 for information on their type, and %Xandra.Cluster.Host{} for more information.

Summary

Types

t()

The type for the host struct.

Functions

The struct that represents a host in a Cassandra cluster.

Formats a host's address and port as a string.

Types

@type t() :: %Xandra.Cluster.Host{
  address: :inet.ip_address() | String.t(),
  data_center: String.t(),
  host_id: String.t(),
  partitioner: String.t() | nil,
  port: :inet.port_number(),
  rack: String.t(),
  release_version: String.t(),
  schema_version: String.t(),
  tokens: MapSet.t(String.t())
}

The type for the host struct.

Fields

  • :address - the address of the host. It can be either an IP address or a hostname. If Xandra managed to connect to this host, then the :address will be the actual IP peer (see :inet.peername/1). Otherwise, the :address will be the parsed IP or the charlist hostname. For example, if you pass "10.0.2.1" as the address, Xandra will normalize it to {10, 0, 2, 1}.

  • :port - the port of the host.

  • :data_center - the data center of the host, as found in the system.local or system.peers table.

  • :host_id - the ID of the host, as found in the system.local or system.peers table.

  • :rack - the rack of the host, as found in the system.local or system.peers table.

  • :release_version - the release version of the host, as found in the system.local or system.peers table.

  • :schema_version - the schema version of the host, as found in the system.local or system.peers table.

  • :tokens - the tokens held by the host, as found in the system.local or system.peers table.

  • :partitioner - the partitioner used by the cluster, as found in the system.local table. This is only present for the host that the control connection is connected to (the system.peers table doesn't have this information), and is nil for all other hosts.

Functions

Link to this function

%Xandra.Cluster.Host{}

View Source (since 0.15.0) (struct)

The struct that represents a host in a Cassandra cluster.

See t/0 for the type of each field.

Link to this function

format_address(host)

View Source (since 0.15.0)
@spec format_address(t()) :: String.t()

Formats a host's address and port as a string.

Examples

iex> host = %Xandra.Cluster.Host{address: {127, 0, 0, 1}, port: 9042}
iex> Xandra.Cluster.Host.format_address(host)
"127.0.0.1:9042"

iex> host = %Xandra.Cluster.Host{address: "example.com", port: 9042}
iex> Xandra.Cluster.Host.format_address(host)
"example.com:9042"