WeaviateEx.Cluster.Node (WeaviateEx v0.7.4)

View Source

Represents a node in the Weaviate cluster.

Nodes are the individual servers that make up a Weaviate cluster. Each node can host shards from multiple collections.

Node Status Values

  • :healthy - Node is operating normally
  • :unhealthy - Node is experiencing issues
  • :unavailable - Node cannot be reached

Examples

%Node{
  name: "node-0",
  status: :healthy,
  version: "1.24.0",
  shards: [%Shard{...}]
}

Summary

Functions

Parse node from API response.

Check if node is healthy.

Parse status string to atom.

Get shards for a specific collection on this node.

Convert status atom to API string.

Get total object count across all shards on this node.

Types

status()

@type status() :: :healthy | :unhealthy | :unavailable

t()

@type t() :: %WeaviateEx.Cluster.Node{
  git_hash: String.t() | nil,
  name: String.t(),
  shards: [WeaviateEx.Cluster.Shard.t()] | nil,
  stats: map() | nil,
  status: status(),
  version: String.t() | nil
}

Functions

from_api(map)

@spec from_api(map()) :: t()

Parse node from API response.

Examples

iex> Node.from_api(%{"name" => "node-0", "status" => "HEALTHY", "version" => "1.24.0"})
%Node{name: "node-0", status: :healthy, version: "1.24.0"}

healthy?(arg1)

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

Check if node is healthy.

Examples

iex> Node.healthy?(%Node{status: :healthy})
true

iex> Node.healthy?(%Node{status: :unhealthy})
false

parse_status(arg1)

@spec parse_status(String.t()) :: status()

Parse status string to atom.

Examples

iex> Node.parse_status("HEALTHY")
:healthy

iex> Node.parse_status("UNHEALTHY")
:unhealthy

shards_for_collection(node, collection)

@spec shards_for_collection(t(), String.t()) :: [WeaviateEx.Cluster.Shard.t()]

Get shards for a specific collection on this node.

Examples

iex> Node.shards_for_collection(node, "Article")
[%Shard{collection: "Article", ...}]

status_to_api(atom)

@spec status_to_api(status()) :: String.t()

Convert status atom to API string.

Examples

iex> Node.status_to_api(:healthy)
"HEALTHY"

total_object_count(node)

@spec total_object_count(t()) :: non_neg_integer()

Get total object count across all shards on this node.

Returns 0 if no shard information is available.

Examples

iex> node = %Node{shards: [%Shard{object_count: 100}, %Shard{object_count: 200}]}
iex> Node.total_object_count(node)
300