# `RpcLoadBalancer.LoadBalancer.Drainer`
[🔗](https://github.com/MikaAK/rpc_load_balancer/blob/main/lib/rpc_load_balancer/load_balancer/drainer.ex#L1)

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.

# `drain`

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

# `in_flight_count`

```elixir
@spec in_flight_count(non_neg_integer()) :: non_neg_integer()
```

# `register`

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

# `release_call`

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

# `track_call`

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
