mirror of
https://github.com/tgdrive/teldrive.git
synced 2025-09-12 01:14:45 +08:00
fix: Add "connection dead" to internalErrors list
This commit is contained in:
parent
e31147aa72
commit
8fe47ba256
1 changed files with 11 additions and 1 deletions
|
@ -18,6 +18,7 @@ var internalErrors = []string{
|
|||
"RPC_MCGET_FAIL",
|
||||
"WORKER_BUSY_TOO_LONG_RETRY",
|
||||
"memory limit exit",
|
||||
"connection dead",
|
||||
}
|
||||
|
||||
type retry struct {
|
||||
|
@ -25,13 +26,22 @@ type retry struct {
|
|||
errors []string
|
||||
}
|
||||
|
||||
func isErrorMatch(err error) bool {
|
||||
for _, internalError := range internalErrors {
|
||||
if errors.Is(err, errors.New(internalError)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (r retry) Handle(next tg.Invoker) telegram.InvokeFunc {
|
||||
return func(ctx context.Context, input bin.Encoder, output bin.Decoder) error {
|
||||
retries := 0
|
||||
|
||||
for retries < r.max {
|
||||
if err := next.Invoke(ctx, input, output); err != nil {
|
||||
if tgerr.Is(err, r.errors...) {
|
||||
if tgerr.Is(err, r.errors...) || isErrorMatch(err) {
|
||||
retries++
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue