TantivyEx.Distributed.Coordinator (TantivyEx v0.4.1)

View Source

Central coordinator for distributed search operations.

This GenServer manages the overall distributed search configuration, orchestrates searches across multiple nodes, and handles failover.

Summary

Functions

Add a search node to the cluster.

Returns a specification to start this module under a supervisor.

Configure the distributed search behavior.

Get list of active nodes.

Get cluster statistics.

Remove a search node from the cluster.

Perform a distributed search across all active nodes.

Set node active/inactive status.

Start the coordinator GenServer.

Types

config()

@type config() :: %{
  timeout_ms: non_neg_integer(),
  max_retries: non_neg_integer(),
  merge_strategy: merge_strategy(),
  load_balancing: load_balancing_strategy(),
  health_check_interval: non_neg_integer()
}

load_balancing_strategy()

@type load_balancing_strategy() ::
  :round_robin | :weighted_round_robin | :least_connections | :health_based

merge_strategy()

@type merge_strategy() :: :score_desc | :score_asc | :node_order | :round_robin

Functions

add_node(coordinator, node_id, endpoint, weight)

@spec add_node(GenServer.server(), String.t(), String.t(), float()) ::
  :ok | {:error, term()}

Add a search node to the cluster.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

configure(coordinator, config)

@spec configure(GenServer.server(), config()) :: :ok | {:error, term()}

Configure the distributed search behavior.

get_active_nodes(coordinator)

@spec get_active_nodes(GenServer.server()) :: {:ok, [String.t()]}

Get list of active nodes.

get_cluster_stats(coordinator)

@spec get_cluster_stats(GenServer.server()) :: {:ok, map()}

Get cluster statistics.

remove_node(coordinator, node_id)

@spec remove_node(GenServer.server(), String.t()) :: :ok | {:error, term()}

Remove a search node from the cluster.

search(coordinator, query, limit, offset)

@spec search(GenServer.server(), term(), non_neg_integer(), non_neg_integer()) ::
  {:ok, map()} | {:error, term()}

Perform a distributed search across all active nodes.

set_node_status(coordinator, node_id, active)

@spec set_node_status(GenServer.server(), String.t(), boolean()) ::
  :ok | {:error, term()}

Set node active/inactive status.

start_link(opts)

Start the coordinator GenServer.