Documentation
¶
Overview ¶
Package invokers contains some middlewares and helpers to work with RPC invokers.
Index ¶
- Constants
- type Object
- type RateLimiter
- type Waiter
- func (w *Waiter) InvokeRaw(ctx context.Context, input bin.Encoder, output bin.Decoder) error
- func (w *Waiter) Run(ctx context.Context) error
- func (w *Waiter) WithClock(c clock.Clock) *Waiter
- func (w *Waiter) WithRetryLimit(retryLimit int) *Waiter
- func (w *Waiter) WithTick(tick time.Duration) *Waiter
- func (w *Waiter) WithWaitLimit(waitLimit int) *Waiter
Examples ¶
Constants ¶
View Source
const ErrFloodWait = "FLOOD_WAIT"
ErrFloodWait is error type of "FLOOD_WAIT" error.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Object ¶
type Object interface {
TypeID() uint32
}
Object is a abstraction for Telegram API object with TypeID.
type RateLimiter ¶ added in v0.39.0
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter is a tg.Invoker that throttles RPC calls on underlying invoker.
Example ¶
package main import ( "time" "golang.org/x/time/rate" "github.com/gotd/td/telegram/invokers" "github.com/gotd/td/tg" ) func main() { var invoker tg.Invoker // e.g. *telegram.Client limiter := invokers.NewRateLimiter(invoker, rate.NewLimiter(rate.Every(100*time.Millisecond), 1), ) tg.NewClient(limiter) }
Output:
func NewRateLimiter ¶ added in v0.39.0
func NewRateLimiter(invoker tg.Invoker, lim *rate.Limiter) *RateLimiter
NewRateLimiter returns a new invoker rate limiter using lim.
func (*RateLimiter) WithClock ¶ added in v0.39.0
func (l *RateLimiter) WithClock(c clock.Clock) *RateLimiter
WithClock sets clock to use. Default is to use system clock.
type Waiter ¶
type Waiter struct {
// contains filtered or unexported fields
}
Waiter is a invoker middleware to handle FLOOD_WAIT errors from Telegram.
func (*Waiter) WithRetryLimit ¶
WithRetryLimit sets retry limit to use.
func (*Waiter) WithWaitLimit ¶
WithWaitLimit sets wait limit to use.
Click to show internal directories.
Click to hide internal directories.