RpcLoadBalancer.LoadBalancer.Drainer (rpc_load_balancer v0.2.1)

Copy Markdown View Source

Tracks in-flight RPC calls and provides graceful connection draining.

Uses DrainerCache (backed by Cache.Counter) to atomically track the number of in-flight calls. During shutdown, the server leaves its :pg group and calls drain/2 to wait for existing calls to complete before the process terminates.

Summary

Functions

drain(drainer_index, timeout \\ 15000)

@spec drain(non_neg_integer(), timeout()) :: :ok | {:error, :timeout}

in_flight_count(drainer_index)

@spec in_flight_count(non_neg_integer()) :: non_neg_integer()

register(load_balancer_name)

@spec register(atom()) :: non_neg_integer()

release_call(drainer_index)

@spec release_call(non_neg_integer()) :: :ok

track_call(drainer_index)

@spec track_call(non_neg_integer()) :: :ok