File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments