network

package
v2.5.0-beta2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRetryFailed = errors.New("callback was unable to complete without errors within the allowed number of retries")

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

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 SetLogger added in v2.3.3

func SetLogger(l logger.Interface)

SetLogger sets the package logger.

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 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