NATS Go ConnPool exhaustion returns ErrPoolEmpty immediately without blocking option
0 reputation · 16 Mar 2020, 12:39 UTC
Connection pool exhaustion behavior
The NATS Go client's ConnPool feature enforces a hard MaxConnections limit. When all pooled connections are in use, NextConnection returns ErrPoolEmpty without blocking the caller. The documented API does not expose a wait or timeout parameter that would allow a caller to queue until a connection becomes available.
Version-dependent error details
Across NATS Go client releases 1.x and 2.x the non-blocking behavior is consistent, yet the concrete error type and message returned by NextConnection have changed between minor versions. This drift makes it difficult to write version-agnostic error handling without inspecting the specific client build.
Open question
Is there a supported pattern or configuration that makes the pool block until a connection is released, or is the immediate ErrPoolEmpty return the only contract? Additionally, does the project publish a stability guarantee for the error type returned on exhaustion so that callers can rely on a single error check across minor releases?