mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
a32d98534c
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.
22 lines
691 B
Go
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")
|
|
)
|