ratelimiter

package
v0.0.0-...-81c02da Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// SessionRateLimit is table name to limit the number of requests per session
	SessionRateLimit = "SessionRateLimit"

	// UserRateLimit is table name to limit the number of sessions per user
	UserRateLimit = "UserRateLimit"

	// ResourceRateLimit is table name to limit the resource on time bound
	ResourceRateLimit = "ResourceRateLimit"
)

Variables

This section is empty.

Functions

func DecrementCounter

func DecrementCounter(key, table string) (int, *errors.Error)

DecrementCounter will decrement the count

func IncrementCounter

func IncrementCounter(key, table string) (int, *errors.Error)

IncrementCounter will increment the count

func RequestRateLimiter

func RequestRateLimiter(ctx context.Context, sessionToken string) error

RequestRateLimiter is for limiting number of requests per session here we will check if count which is added db against the session token if count is exceded the limit then return the response with too many requests, retry after some time if its not exceded then increment the counter and when the request completes the task then decrement the counter

func ResourceRateLimiter

func ResourceRateLimiter(ctx iris.Context)

ResourceRateLimiter will Limit the get on resource untill previous get completed the task

func SessionRateLimiter

func SessionRateLimiter(ctx context.Context, userid string) error

SessionRateLimiter is for limiting number of sessions per user here we will check if count which is added db against the user id if count is exceded the limit then return the response with too many requests, retry after some time if its not exceded then incremen the counter and when the request completes the task then decrement the counter

Types

This section is empty.

Jump to

Keyboard shortcuts

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