View Source Xandra.Cluster.LoadBalancingPolicy behaviour (Xandra v0.19.2)
A behaviour for defining load-balancing policies.
A load-balancing policy is a way to tell Xandra which nodes to query when connected to a cluster.
For example, a simple load-balancing policy is Xandra.Cluster.LoadBalancingPolicy.Random
,
which picks a random node for each query out of the ones that are up.
Summary
Callbacks
Called when the Cassandra cluster reports a new host that joined.
Called when Xandra successfully connects to host
.
Called when the Cassandra cluster marks host
as "down".
Called when the Cassandra cluster reports a host that left the cluster.
Called when the Cassandra gossip marks host
as "up".
Called to return a "plan", which is an enumerable of hosts to start connections in order.
Called to initialize the load-balancing policy.
Called to return a "plan", which is an enumerable of hosts to query in order.
Types
@type state() :: term()
The state of the load-balancing policy.
Can be any term and is passed around to all callbacks.
Callbacks
@callback host_added(state(), host :: Xandra.Cluster.Host.t()) :: state()
Called when the Cassandra cluster reports a new host that joined.
@callback host_connected(state(), host :: Xandra.Cluster.Host.t()) :: state()
Called when Xandra successfully connects to host
.
@callback host_down(state(), host :: Xandra.Cluster.Host.t()) :: state()
Called when the Cassandra cluster marks host
as "down".
@callback host_removed(state(), host :: Xandra.Cluster.Host.t()) :: state()
Called when the Cassandra cluster reports a host that left the cluster.
@callback host_up(state(), host :: Xandra.Cluster.Host.t()) :: state()
Called when the Cassandra gossip marks host
as "up".
@callback hosts_plan(state()) :: {Enumerable.t(Xandra.Cluster.Host.t()), state()}
Called to return a "plan", which is an enumerable of hosts to start connections in order.
Called to initialize the load-balancing policy.
options
is given by the user when configuring the cluster, and is specific to
the load-balancing policy.
@callback query_plan(state()) :: {Enumerable.t(Xandra.Cluster.Host.t()), state()}
Called to return a "plan", which is an enumerable of hosts to query in order.