Files
picoclaw/pkg/channels/errors.go
T
Hoshina a32d98534c refactor(channels): add per-channel rate limiting and send retry with error classification
Define sentinel error types (ErrNotRunning, ErrRateLimit, ErrTemporary,
ErrSendFailed) so the Manager can classify Send failures and choose the
right retry strategy: permanent errors bail immediately, rate-limit
errors use a fixed 1s delay, and temporary/unknown errors use exponential
backoff (500ms→1s→2s, capped at 8s, up to 3 retries). A per-channel
token-bucket rate limiter (golang.org/x/time/rate) throttles outbound
sends before they hit the platform API.
2026-02-24 12:10:45 +08:00

22 lines
691 B
Go

package channels
import "errors"
var (
// ErrNotRunning indicates the channel is not running.
// Manager will not retry.
ErrNotRunning = errors.New("channel not running")
// ErrRateLimit indicates the platform returned a rate-limit response (e.g. HTTP 429).
// Manager will wait a fixed delay and retry.
ErrRateLimit = errors.New("rate limited")
// ErrTemporary indicates a transient failure (e.g. network timeout, 5xx).
// Manager will use exponential backoff and retry.
ErrTemporary = errors.New("temporary failure")
// ErrSendFailed indicates a permanent failure (e.g. invalid chat ID, 4xx non-429).
// Manager will not retry.
ErrSendFailed = errors.New("send failed")
)