ratelimit

package
v2.3.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRateLimited = errors.New("rate limit reached")

ErrRateLimited is returned if the rate limit has been reached

Functions

This section is empty.

Types

type Limits

type Limits struct {
	Uplink   int
	Downlink int
	Status   int
}

Limits per minute

type RateLimit

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

RateLimit uplink, downlink and status messages per gateway

func NewRateLimit

func NewRateLimit(conf Limits) *RateLimit

NewRateLimit returns a middleware that rate-limits uplink, downlink and status messages per gateway

func NewRedisRateLimit

func NewRedisRateLimit(client *redis.Client, conf Limits) *RateLimit

NewRedisRateLimit returns a middleware that rate-limits uplink, downlink and status messages per gateway

func (*RateLimit) HandleConnect

func (l *RateLimit) HandleConnect(ctx middleware.Context, msg *types.ConnectMessage) error

HandleConnect initializes the rate limiter

func (*RateLimit) HandleDisconnect

func (l *RateLimit) HandleDisconnect(ctx middleware.Context, msg *types.DisconnectMessage) error

HandleDisconnect cleans up

func (l *RateLimit) HandleDownlink(ctx middleware.Context, msg *types.DownlinkMessage) error

HandleDownlink rate-limits downlink messages

func (*RateLimit) HandleStatus

func (l *RateLimit) HandleStatus(ctx middleware.Context, msg *types.StatusMessage) error

HandleStatus rate-limits status messages

func (l *RateLimit) HandleUplink(ctx middleware.Context, msg *types.UplinkMessage) error

HandleUplink rate-limits status messages

Jump to

Keyboard shortcuts

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