limit

package
v1.0.0-...-a0f063d Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PerDay

func PerDay(maxAttempts int) contractshttp.ILimit

func PerDays

func PerDays(decayDays, maxAttempts int) contractshttp.ILimit

func PerHour

func PerHour(maxAttempts int) contractshttp.ILimit

func PerHours

func PerHours(decayHours, maxAttempts int) contractshttp.ILimit

func PerMinute

func PerMinute(maxAttempts int) contractshttp.ILimit

func PerMinutes

func PerMinutes(decayMinutes, maxAttempts int) contractshttp.ILimit

Types

type Limit

type Limit struct {
	// The rate limit signature key.
	Key string
	// The maximum number of attempts allowed within the given number of minutes.
	MaxAttempts int
	// The number of minutes until the rate limit is reset.
	DecayMinutes int
	// The response generator callback.
	ResponseCallback func(ctx contractshttp.Context)
}

func NewLimit

func NewLimit(maxAttempts, decayMinutes int) *Limit

func (*Limit) By

func (r *Limit) By(key string) contractshttp.ILimit

func (*Limit) Response

func (r *Limit) Response(callable func(ctx contractshttp.Context)) contractshttp.ILimit

Jump to

Keyboard shortcuts

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