LimitBandwidth

package
v0.7.10 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LimitBandwidthType

type LimitBandwidthType struct {
	Next          http.Handler //
	Paths         []string     //
	FreqMiliKey   string       // QT template for lookup of Redis key
	HttpErrorCode int          //
	FreqMili      int          // sequence for request in milliseconds
	PerAuthCfgKey string       // QT template for using a non-default timeout, can be set to "inf" - for no limit on time.
	NPerSecKey    string       // QT template for the N Per Second
	NPerSecond    int          // if 0 then will not apply
	AuthTokenName string       // The name of the "auth_token" could be "$user_id$" for logged in users
	LineNo        int          //
	// contains filtered or unexported fields
}

func NewLimitBandwidthServer

func NewLimitBandwidthServer(n http.Handler, p []string, pFreqMili, pNPerSecond int) *LimitBandwidthType

func (*LimitBandwidthType) InitializeWithConfigData

func (hdlr *LimitBandwidthType) InitializeWithConfigData(next http.Handler, gCfg *cfg.ServerGlobalConfigType, serverName string, pNo, callNo int) (err error)

func (*LimitBandwidthType) PreValidate

func (hdlr *LimitBandwidthType) PreValidate(gCfg *cfg.ServerGlobalConfigType, cfgData map[string]interface{}, serverName string, pNo, callNo int) (err error)

func (*LimitBandwidthType) RedisGet

func (hdlr *LimitBandwidthType) RedisGet(key string) (val string, err error)

func (*LimitBandwidthType) RedisSetFreqMili

func (hdlr *LimitBandwidthType) RedisSetFreqMili(key string, ttlMilisec int, val string) (err error)

func (*LimitBandwidthType) RedisSetIncrementNPerSecond

func (hdlr *LimitBandwidthType) RedisSetIncrementNPerSecond(key string) (nSoFar int, err error)

func (*LimitBandwidthType) ServeHTTP

func (hdlr *LimitBandwidthType) ServeHTTP(www http.ResponseWriter, req *http.Request)

type PerAuthCfg

type PerAuthCfg struct {
	FreqMili   int
	NPerSecond int
}

PerAuthCfgKey is JSON data

{ "FreqMili": -1, 			// unlimited
{ "FreqMili": 0, 			// turned off
{ "FreqMili": 1500, 		// 1.5  seconds between requests
{ "FreqMili":0,"NPerSecond": -1		// unlimited
{ "FreqMili":0 "NPerSecond": 0			// Check not applicable
{ "FreqMili":0 "NPerSecond": 200		// Allow up to 200 request per second.

Jump to

Keyboard shortcuts

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