Skip to content

Commit 5574793

Browse files
ndyakovCopilot
andauthored
Update redis.go
Co-authored-by: Copilot <[email protected]>
1 parent c6f4820 commit 5574793

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

redis.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,16 @@ func NewClient(opt *Options) *Client {
930930
if err != nil {
931931
internal.Logger.Printf(context.Background(), "hitless: failed to initialize hitless upgrades: %v", err)
932932
if opt.HitlessUpgradeConfig.Mode == hitless.MaintNotificationsEnabled {
933-
// panic so we fail fast without breaking existing clients api
933+
/*
934+
Design decision: panic here to fail fast if hitless upgrades cannot be enabled when explicitly requested.
935+
We choose to panic instead of returning an error to avoid breaking the existing client API, which does not expect
936+
an error from NewClient. This ensures that misconfiguration or critical initialization failures are surfaced
937+
immediately, rather than allowing the client to continue in a partially initialized or inconsistent state.
938+
Clients relying on hitless upgrades should be aware that initialization errors will cause a panic, and should
939+
handle this accordingly (e.g., via recover or by validating configuration before calling NewClient).
940+
This approach is only used when HitlessUpgradeConfig.Mode is MaintNotificationsEnabled, indicating that hitless
941+
upgrades are required for correct operation. In other modes, initialization failures are logged but do not panic.
942+
*/
934943
panic(fmt.Errorf("failed to enable hitless upgrades: %w", err))
935944
}
936945
}

0 commit comments

Comments
 (0)