middlewares

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultRetryAfter = "3"
	DefaultWaiting    = 3 * time.Second
)
View Source
const (
	// HeaderRateLimitRemaining = "X-RateLimit-Remaining"
	HeaderRetryAfter = "Retry-After"
)

Variables

View Source
var (
	ErrGetCPUUtilizationFail = errors.New("get CPU utilization fails")
	ErrGetRAMUsedFail        = errors.New("get RAM used fails")
	ErrClosedResourcer       = errors.New("the resourcer is closed")
	ErrResourcerNoResult     = errors.New("resourcer fails with no result")
)
View Source
var DefaultCommonConfig = CommonConfig{
	MemoryUsageBarrierPercentage:    rate.DefaultMemoryUsageBarrierPercentage,
	CPUUtilizationBarrierPercentage: rate.DefaultCPUUtilizationBarrierPercentage,
	Debug:                           false,
}

Functions

func ErrorLimitHandler added in v0.1.4

func ErrorLimitHandler(logger multilog.Logger, c Client, err error, now time.Time)

func ErrorThrottleHandler added in v0.1.4

func ErrorThrottleHandler(logger multilog.Logger, c Client, err error, now time.Time)

func LimitHandler added in v0.1.4

func LimitHandler(logger multilog.Logger, c Client, now time.Time)

func ThrottleHandler added in v0.1.4

func ThrottleHandler(logger multilog.Logger, c Client, now time.Time)

Types

type Client added in v0.1.4

type Client struct {
	IP   string
	Path string
}

type CommonConfig added in v0.1.2

type CommonConfig struct {
	// MemoryUsageBarrierPercentage the memory usage barrier after which the rate is enabled
	MemoryUsageBarrierPercentage float64

	// CPUUtilizationBarrierPercentage the CPU utilization barrier after which the rate is enabled
	CPUUtilizationBarrierPercentage float64

	// может быть nil
	Logger multilog.Logger

	Debug bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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