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

Types

The state of the load-balancing policy.

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

Link to this type

state()

View Source (since 0.15.0)
@type state() :: term()

The state of the load-balancing policy.

Can be any term and is passed around to all callbacks.

Callbacks

Link to this callback

host_added(state, host)

View Source (since 0.15.0)
@callback host_added(state(), host :: Xandra.Cluster.Host.t()) :: state()

Called when the Cassandra cluster reports a new host that joined.

Link to this callback

host_connected(state, host)

View Source (since 0.15.0)
@callback host_connected(state(), host :: Xandra.Cluster.Host.t()) :: state()

Called when Xandra successfully connects to host.

Link to this callback

host_down(state, host)

View Source (since 0.15.0)
@callback host_down(state(), host :: Xandra.Cluster.Host.t()) :: state()

Called when the Cassandra cluster marks host as "down".

Link to this callback

host_removed(state, host)

View Source (since 0.15.0)
@callback host_removed(state(), host :: Xandra.Cluster.Host.t()) :: state()

Called when the Cassandra cluster reports a host that left the cluster.

Link to this callback

host_up(state, host)

View Source (since 0.15.0)
@callback host_up(state(), host :: Xandra.Cluster.Host.t()) :: state()

Called when the Cassandra gossip marks host as "up".

Link to this callback

hosts_plan(state)

View Source (since 0.15.0)
@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.

Link to this callback

init(options)

View Source (since 0.15.0)
@callback init(options :: term()) :: state()

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.

Link to this callback

query_plan(state)

View Source (since 0.15.0)
@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.