Shared atomic counters for slot-based round-robin and per-node connection tracking across all load balancers.
Summary
Functions
Returns the underlying :counters reference for the shared counter cache.
Atomically decrements the counter for the given key by step (default 1).
Read a node's connection count without telemetry overhead.
Atomically increments the counter for the given key by step (default 1).
Functions
@spec counter_ref() :: :counters.counters_ref()
Returns the underlying :counters reference for the shared counter cache.
Hot-path callers cache this once per selection (or per process) and
use :counters.get/2 / :counters.add/3 directly instead of paying
the :telemetry.span/3 overhead of Cache.get/1 per read.
Atomically decrements the counter for the given key by step (default 1).
@spec get_and_increment(non_neg_integer()) :: non_neg_integer()
@spec get_node_count(atom(), node()) :: non_neg_integer()
Read a node's connection count without telemetry overhead.
Goes straight to :counters.get/2, skipping the
:telemetry.span/3-wrapped Cache.get/1. Returns 0 for nodes that
haven't been registered yet so callers can treat a missing entry as
the natural "lowest" candidate.
Atomically increments the counter for the given key by step (default 1).
@spec register(atom(), pos_integer()) :: non_neg_integer()
@spec register_node(atom(), node()) :: non_neg_integer()
@spec reset_counter(non_neg_integer()) :: :ok