network

package
v2.5.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLimiter

func NewLimiter(t Tier, burst uint, boost int) *rate.Limiter

NewLimiter returns throttler with rateLimit requests per minute. optionally caller may specify the boost

func SetMaxAllowedWaitTime added in v2.3.3

func SetMaxAllowedWaitTime(d time.Duration)

SetMaxAllowedWaitTime sets the maximum time to wait for a transient error.

func WithRetry

func WithRetry(ctx context.Context, lim *rate.Limiter, maxAttempts int, fn func() error) error

WithRetry will run the callback function fn. If the function returns slack.RateLimitedError, it will delay, and then call it again up to maxAttempts times. It will return an error if it runs out of attempts.

Types

type ErrRetryFailed

type ErrRetryFailed struct {
	Err error
}

ErrRetryFailed is returned if number of retry attempts exceeded the retry attempts limit and function wasn't able to complete without errors.

func (*ErrRetryFailed) Error added in v2.5.8

func (e *ErrRetryFailed) Error() string

func (*ErrRetryFailed) Is added in v2.5.8

func (e *ErrRetryFailed) Is(target error) bool

func (*ErrRetryFailed) Unwrap added in v2.5.8

func (e *ErrRetryFailed) Unwrap() error

type Tier

type Tier int

Tier represents rate limit Tier: https://api.slack.com/docs/rate-limits

const (
	// base throttling defined as events per minute
	NoTier Tier = 6000 // no Tier is applied

	// Tier1 Tier = 1
	Tier2 Tier = 20
	Tier3 Tier = 50
	Tier4 Tier = 100
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL