From 55747935a39632ada8701cad61f12b69c065b7c8 Mon Sep 17 00:00:00 2001 From: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com> Date: Tue, 19 Aug 2025 15:39:20 +0300 Subject: [PATCH] Update redis.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- redis.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/redis.go b/redis.go index e5cca4af..27bd6b7e 100644 --- a/redis.go +++ b/redis.go @@ -930,7 +930,16 @@ func NewClient(opt *Options) *Client { if err != nil { internal.Logger.Printf(context.Background(), "hitless: failed to initialize hitless upgrades: %v", err) if opt.HitlessUpgradeConfig.Mode == hitless.MaintNotificationsEnabled { - // panic so we fail fast without breaking existing clients api + /* + Design decision: panic here to fail fast if hitless upgrades cannot be enabled when explicitly requested. + We choose to panic instead of returning an error to avoid breaking the existing client API, which does not expect + an error from NewClient. This ensures that misconfiguration or critical initialization failures are surfaced + immediately, rather than allowing the client to continue in a partially initialized or inconsistent state. + Clients relying on hitless upgrades should be aware that initialization errors will cause a panic, and should + handle this accordingly (e.g., via recover or by validating configuration before calling NewClient). + This approach is only used when HitlessUpgradeConfig.Mode is MaintNotificationsEnabled, indicating that hitless + upgrades are required for correct operation. In other modes, initialization failures are logged but do not panic. + */ panic(fmt.Errorf("failed to enable hitless upgrades: %w", err)) } }