sdk: make auto-reconnect backoff configurable via the builder#5527
Open
DexterKoelson wants to merge 1 commit into
Open
sdk: make auto-reconnect backoff configurable via the builder#5527DexterKoelson wants to merge 1 commit into
DexterKoelson wants to merge 1 commit into
Conversation
Add DbConnectionBuilder.withReconnectOptions({ baseDelayMs, maxDelayMs }) and a
getReconnectOptions() accessor. connectionManagerReconnectDelayMs now takes
optional overrides, and #scheduleReconnect reads them from the retained
builder, so the exponential backoff is configurable per connection instead of
fixed at the module 1000ms/30000ms constants.
baseDelayMs is the delay before the first retry (the minimum backoff) and
doubles each attempt up to maxDelayMs. Unset fields keep the defaults. Invalid
values (non-positive, non-finite, or base > max) throw. The ReconnectOptions
type is exported from the package root.
Applies to connections retained through the ConnectionManager (the React and
Solid providers); a connection built and used directly does not auto-reconnect.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #5526
Description of Changes
Add
DbConnectionBuilder.withReconnectOptions({ baseDelayMs?, maxDelayMs? })and agetReconnectOptions()accessor.baseDelayMsis the delay before the first retry (the minimum backoff) and doubles on each consecutive failure up tomaxDelayMs. Unset fields keep the current defaults (1000 ms base, 30000 ms max). Invalid values (non-positive, non-finite, orbaseDelayMs > maxDelayMs) throw aTypeError.connectionManagerReconnectDelayMs(attempt, options?)now takes optional overrides, andConnectionManager.#scheduleReconnectreads them from the retained builder, so the backoff is per connection rather than global. TheReconnectOptionstype is exported from the package root.Applies to connections retained through the
ConnectionManager(the React and Solid providers). It has no effect on a connection built and used directly viabuild(), which does not auto-reconnect.API and ABI breaking changes
None.
withReconnectOptions/getReconnectOptionsand theReconnectOptionstype are new, and the extraconnectionManagerReconnectDelayMsparameter is optional, so existing callers are unaffected.Expected complexity level and risk
The change is additive and localized to the builder and the reconnect delay computation. Behavior is unchanged unless
withReconnectOptionsis called, in which case only the backoff timing differs.Testing
(Disclaimer: all tests were AI generated)
tests/db_connection.test.tscover storage, single-field overrides, and validation errors.tests/connection_manager_reconnect.test.tscovers the delay function overrides and an end-to-end retained reconnect using custom delays.