rate

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2020 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const ExtraDelay = 250 * time.Millisecond

ExtraDelay because Discord is trash. I've seen this in both litcord and discordgo, with dgo claiming from his experiments. RE: Those who want others to fix it for them: release the source code then.

Variables

View Source
var MajorRootPaths = []string{"channels", "guilds"}

TODO: webhook

Functions

func EmojiRune added in v0.1.1

func EmojiRune(r rune) bool

func ParseBucketKey

func ParseBucketKey(path string) string

func StringIsCustomEmoji added in v0.1.1

func StringIsCustomEmoji(emoji string) bool

func StringIsEmojiOnly added in v0.1.1

func StringIsEmojiOnly(emoji string) bool

Types

type CustomRateLimit

type CustomRateLimit struct {
	Contains string
	Reset    time.Duration
}

type Limiter

type Limiter struct {
	// Only 1 per bucket
	CustomLimits []*CustomRateLimit

	// These callbacks will only be called for valid buckets. They will also be
	// called right before locking. Returning false will not rate limit.
	OnAcquire func(path string) bool
	OnCancel  func(path string) bool
	OnRelease func(path string) bool // false means not unlocking

	Prefix string
	// contains filtered or unexported fields
}

func NewLimiter

func NewLimiter(prefix string) *Limiter

func (*Limiter) Acquire

func (l *Limiter) Acquire(ctx context.Context, path string) error

func (*Limiter) Cancel added in v0.1.2

func (l *Limiter) Cancel(path string) error

func (*Limiter) Release

func (l *Limiter) Release(path string, headers http.Header) error

Release releases the URL from the locks. This doesn't need a context for timing out, it doesn't block that much.

Jump to

Keyboard shortcuts

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