Files
ai_site/platform/internal/dbsync/retryable.go
whm b04b180d30 feat: harden loose-offline sync for user JWT, schema, and console ops
Enable Binding-scoped agent push/pull, empty-table schema ensure, SyncPage inspect/drop-table, default module import, and agent-bound publish docs from the 宇恒联调意见.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-05 09:47:35 +08:00

52 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package dbsync
import (
"errors"
"fmt"
"strings"
)
// RetryableError 上游 IO / remote 暂不可达agent 可稍后重试(不换 UUID
type RetryableError struct {
Msg string
}
func (e *RetryableError) Error() string {
if e == nil {
return "retryable error"
}
return e.Msg
}
func Retryable(msg string) error {
return &RetryableError{Msg: msg}
}
func Retryablef(format string, args ...any) error {
return &RetryableError{Msg: fmt.Sprintf(format, args...)}
}
func IsRetryable(err error) bool {
var r *RetryableError
return errors.As(err, &r)
}
func wrapOpenRemote(err error) error {
if err == nil {
return nil
}
msg := err.Error()
lower := strings.ToLower(msg)
if strings.Contains(lower, "open remote") ||
strings.Contains(lower, "unable to open") ||
strings.Contains(lower, "no such file") ||
strings.Contains(lower, "locked") ||
strings.Contains(lower, "busy") ||
strings.Contains(lower, "connection refused") ||
strings.Contains(lower, "timeout") ||
strings.Contains(lower, "i/o") {
return Retryablef("open remote: %v", err)
}
return Retryablef("open remote: %v", err)
}