rename error
This commit is contained in:
committed by
Jack Christensen
parent
618a12a094
commit
cdc240d920
@@ -822,7 +822,7 @@ func ValidateConnectTargetSessionAttrsPreferStandby(ctx context.Context, pgConn
|
|||||||
}
|
}
|
||||||
|
|
||||||
if string(result.Rows[0][0]) != "t" {
|
if string(result.Rows[0][0]) != "t" {
|
||||||
return &NotStandbyError{err: errors.New("server is not in hot standby mode")}
|
return &NotPreferredError{err: errors.New("server is not in hot standby mode")}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -220,19 +220,19 @@ func redactURL(u *url.URL) string {
|
|||||||
return u.String()
|
return u.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
type NotStandbyError struct {
|
type NotPreferredError struct {
|
||||||
err error
|
err error
|
||||||
safeToRetry bool
|
safeToRetry bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *NotStandbyError) Error() string {
|
func (e *NotPreferredError) Error() string {
|
||||||
return fmt.Sprintf("standby server not found: %s", e.err.Error())
|
return fmt.Sprintf("standby server not found: %s", e.err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *NotStandbyError) SafeToRetry() bool {
|
func (e *NotPreferredError) SafeToRetry() bool {
|
||||||
return e.safeToRetry
|
return e.safeToRetry
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *NotStandbyError) Unwrap() error {
|
func (e *NotPreferredError) Unwrap() error {
|
||||||
return e.err
|
return e.err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ func ConnectConfig(ctx context.Context, config *Config) (pgConn *PgConn, err err
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
} else if cerr, ok := err.(*connectError); ok {
|
} else if cerr, ok := err.(*connectError); ok {
|
||||||
if _, ok := cerr.err.(*NotStandbyError); ok {
|
if _, ok := cerr.err.(*NotPreferredError); ok {
|
||||||
fallbackConfig = fc
|
fallbackConfig = fc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user