(fix): polling retry-after
Golang lint / lint (pull_request) Successful in 3m4s
Golang lint / lint (push) Successful in 3m8s

(tests): polling rate-limit

(doc): changelog update
This commit is contained in:
2026-05-08 14:11:58 +03:00
parent daa1b862ed
commit 5959d69945
6 changed files with 110 additions and 6 deletions
+13
View File
@@ -2,6 +2,7 @@ package laniakea
import (
"context"
"errors"
"fmt"
"maps"
"reflect"
@@ -135,6 +136,18 @@ func nextPollRetryDelay(prev time.Duration) time.Duration {
return next
}
func pollRetryAfterDelay(err error) (time.Duration, bool) {
var responseErr *tgapi.ResponseError
if !errors.As(err, &responseErr) || responseErr.Code != 429 || responseErr.Parameters == nil || responseErr.Parameters.RetryAfter == nil {
return 0, false
}
after := *responseErr.Parameters.RetryAfter
if after <= 0 {
return 0, false
}
return time.Duration(after) * time.Second, true
}
func isNilValue[T any](v T) bool {
rv := reflect.ValueOf(v)
if !rv.IsValid() {