Documentation ¶
Overview ¶
Package floodwait implements a tg.Invoker that handles flood wait errors.
Index ¶
- type SimpleWaiter
- type Waiter
- func (w *Waiter) Handle(next tg.Invoker) telegram.InvokeFunc
- func (w *Waiter) Run(ctx context.Context) error
- func (w *Waiter) WithClock(c clock.Clock) *Waiter
- func (w *Waiter) WithMaxRetries(m int) *Waiter
- func (w *Waiter) WithMaxWait(m time.Duration) *Waiter
- func (w *Waiter) WithTick(t time.Duration) *Waiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SimpleWaiter ¶
type SimpleWaiter struct {
// contains filtered or unexported fields
}
SimpleWaiter is a tg.Invoker that handles flood wait errors on underlying invoker.
This implementation is more suitable for one-off tasks and programs with low level of concurrency and parallelism.
See Waiter for a fully-blown scheduler-based flood wait handler.
func NewSimpleWaiter ¶
func NewSimpleWaiter() *SimpleWaiter
NewSimpleWaiter returns a new invoker that waits on the flood wait errors.
func (*SimpleWaiter) Handle ¶
func (w *SimpleWaiter) Handle(next tg.Invoker) telegram.InvokeFunc
Handle implements telegram.Middleware.
func (*SimpleWaiter) WithClock ¶
func (w *SimpleWaiter) WithClock(c clock.Clock) *SimpleWaiter
WithClock sets clock to use. Default is to use system clock.
func (*SimpleWaiter) WithMaxRetries ¶
func (w *SimpleWaiter) WithMaxRetries(m uint) *SimpleWaiter
WithMaxRetries sets max number of retries before giving up. Default is to keep retrying on flood wait errors indefinitely.
func (*SimpleWaiter) WithMaxWait ¶
func (w *SimpleWaiter) WithMaxWait(m time.Duration) *SimpleWaiter
WithMaxWait limits wait time per attempt. SimpleWaiter will return an error if flood wait time exceeds that limit. Default is to wait without time limit.
To limit total wait time use a context.Context with timeout or deadline set.
type Waiter ¶
type Waiter struct {
// contains filtered or unexported fields
}
Waiter is a tg.Invoker that handles flood wait errors on underlying invoker.
This implementation uses a request scheduler and is more suitable for long-running programs with high level of concurrency and parallelism.
You should use Waiter if unsure which waiter implementation to use.
See SimpleWaiter for a simple timer-based implementation.
func NewWaiter ¶
func NewWaiter() *Waiter
NewWaiter returns a new invoker that waits on the flood wait errors.
func (*Waiter) Handle ¶
func (w *Waiter) Handle(next tg.Invoker) telegram.InvokeFunc
Handle implements telegram.Middleware.
func (*Waiter) WithMaxRetries ¶
WithMaxRetries sets max number of retries before giving up. Default is to retry at most 5 times.
func (*Waiter) WithMaxWait ¶
WithMaxWait limits wait time per attempt. Waiter will return an error if flood wait time exceeds that limit. Default is to wait at most a minute.
To limit total wait time use a context.Context with timeout or deadline set.