limiter

package
v0.0.0-...-ca9cc58 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// same IP can submit x tasks per 24 hours
	IP = &Limiter{
		name: "limitIP",
		max:  10,
		c:    cache.New(day, time.Hour),
	}

	// a task can sent x emails before the resume
	Sent = &Limiter{
		name: "limitSent",
		max:  5,
		c:    cache.New(day*365, day*365),
	}

	// one address can receive x emails per 24 hours
	Recv = &Limiter{
		name: "limitRecv",
		max:  50,
		c:    cache.New(day, time.Hour),
	}
)
View Source
var (
	ErrExceeded = errors.New("can not handle your request due to limiter")
)

error

Functions

This section is empty.

Types

type Limiter

type Limiter struct {
	// contains filtered or unexported fields
}

func (*Limiter) Dec

func (l *Limiter) Dec(k string)

func (*Limiter) Inc

func (l *Limiter) Inc(k string) error

func (*Limiter) Reset

func (l *Limiter) Reset(k string)

Jump to

Keyboard shortcuts

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