limiter

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const ResetScript = `` /* 286-byte string literal not displayed */
View Source
const Script = `` /* 1902-byte string literal not displayed */
View Source
const TimeFormat = "2006-01-02 15:04:05"

for the deadline time format.

Variables

View Source
var (
	LimitError   = errors.New("Limit should > 0.")
	CommandError = errors.New("The command of first number should > 0.")
	FormatError  = errors.New("Please check the format with your input.")
	MethodError  = errors.New("Please check the method is one of http method.")
	ServerError  = errors.New("StatusInternalServerError, please wait a minute.")
)

self define error

Functions

This section is empty.

Types

type Dispatcher

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

func LimitDispatcher

func LimitDispatcher(command string, limit int, rdb *redis.Client) (*Dispatcher, error)

create a limit dispatcher object with command and limit request number.

func (*Dispatcher) GetDeadLine

func (dispatch *Dispatcher) GetDeadLine() int64

get the deadline with unix time.

func (*Dispatcher) GetDeadLineWithString

func (dispatch *Dispatcher) GetDeadLineWithString() string

get the deadline with format 2006-01-02 15:04:05

func (*Dispatcher) GetLimit

func (dispathch *Dispatcher) GetLimit() int

get the limit

func (*Dispatcher) GetSHAScript

func (dispatch *Dispatcher) GetSHAScript(index string) string

func (*Dispatcher) MiddleWare

func (dispatch *Dispatcher) MiddleWare(command string, limit int) gin.HandlerFunc

func (*Dispatcher) ParseCommand

func (dispatch *Dispatcher) ParseCommand(command string) (time.Duration, error)

func (*Dispatcher) UpdateDeadLine

func (dispatch *Dispatcher) UpdateDeadLine()

update the deadline

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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