ReconnectToServerHandler is invoked on every connection attempt (initial
connect and reconnects). It receives a snapshot of the current server pool,
with the server the client would have selected at index 0, and the most
recent ServerInfo (null on initial connect, before any INFO has been
received).
Return one of:
a Server from the (possibly mutated) pool: the client will dial it
immediately.
{ server, delay }: the client will wait delay milliseconds (on top
of any reconnect backoff already applied) before dialing server.
Useful for application-level pacing — not for reconnect backoff
(configure that via ConnectionOptions.reconnectDelayHandler).
The delay is interruptible by nc.close().
null: defer to default selection (pool[0]).
The handler must be synchronous and must not throw. If it throws or
returns a Server that is not in the pool, the connection is rejected on
initial connect or closed on reconnect with a ConnectionError wrapping
the underlying cause.
Reconnect backoff (reconnectTimeWait, reconnectJitter,
reconnectDelayHandler) is applied by the client before invoking this
handler — the handler only selects which server to dial, and may
optionally request additional pre-dial delay via the {server, delay}
return shape.
ReconnectToServerHandler is invoked on every connection attempt (initial connect and reconnects). It receives a snapshot of the current server pool, with the server the client would have selected at index 0, and the most recent ServerInfo (null on initial connect, before any INFO has been received).
Return one of:
Serverfrom the (possibly mutated) pool: the client will dial it immediately.{ server, delay }: the client will waitdelaymilliseconds (on top of any reconnect backoff already applied) before dialingserver. Useful for application-level pacing — not for reconnect backoff (configure that via ConnectionOptions.reconnectDelayHandler). The delay is interruptible bync.close().null: defer to default selection (pool[0]).The handler must be synchronous and must not throw. If it throws or returns a Server that is not in the pool, the connection is rejected on initial connect or closed on reconnect with a ConnectionError wrapping the underlying cause.
Reconnect backoff (reconnectTimeWait, reconnectJitter, reconnectDelayHandler) is applied by the client before invoking this handler — the handler only selects which server to dial, and may optionally request additional pre-dial delay via the
{server, delay}return shape.