config

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const NearLimitRatio = 0.8

The NearLimitRation constant defines the ratio of total_hits over the Limit's RequestPerUnit that need to happen before triggering a near_limit stat increase

Variables

This section is empty.

Functions

This section is empty.

Types

type RateLimit

type RateLimit struct {
	FullKey string
	Stats   RateLimitStats
	Limit   *pb.RateLimitResponse_RateLimit
}

Wrapper for an individual rate limit config entry which includes the defined limit and stats.

func NewRateLimit

func NewRateLimit(
	requestsPerUnit uint32, unit pb.RateLimitResponse_RateLimit_Unit, key string, scope stats.Scope) *RateLimit

Create a new rate limit config entry. @param requestsPerUnit supplies the requests per unit of time for the entry. @param unit supplies the unit of time for the entry. @param key supplies the fully resolved key name of the entry. @param scope supplies the owning scope. @return the new config entry.

type RateLimitConfig

type RateLimitConfig interface {
	// Dump the configuration into string form for debugging.
	Dump() string

	// Get the configured limit for a rate limit descriptor.
	// @param ctx supplies the calling context.
	// @param domain supplies the domain to lookup the descriptor in.
	// @param descriptor supplies the descriptor to look up.
	// @return a rate limit to apply or nil if no rate limit is configured for the descriptor.
	GetLimit(ctx context.Context, domain string, descriptor *pb_struct.RateLimitDescriptor) *RateLimit
}

Interface for interacting with a loaded rate limit config.

func NewRateLimitConfigImpl

func NewRateLimitConfigImpl(
	configs []RateLimitConfigToLoad, statsScope stats.Scope) RateLimitConfig

Create rate limit config from a list of input YAML files. @param configs specifies a list of YAML files to load. @param stats supplies the stats scope to use for limit stats during runtime. @return a new config.

type RateLimitConfigError

type RateLimitConfigError string

Errors that may be raised during config parsing.

func (RateLimitConfigError) Error

func (e RateLimitConfigError) Error() string

type RateLimitConfigLoader

type RateLimitConfigLoader interface {
	// Load a new configuration from a list of YAML files.
	// @param configs supplies a list of full YAML files in string form.
	// @param statsScope supplies the stats scope to use for limit stats during runtime.
	// @return a new configuration.
	// @throws RateLimitConfigError if the configuration could not be created.
	Load(configs []RateLimitConfigToLoad, statsScope stats.Scope) RateLimitConfig
}

Interface for loading a configuration from a list of YAML files.

func NewRateLimitConfigLoaderImpl

func NewRateLimitConfigLoaderImpl() RateLimitConfigLoader

@return a new default config loader implementation.

type RateLimitConfigToLoad

type RateLimitConfigToLoad struct {
	Name      string
	FileBytes string
}

Information for a config file to load into the aggregate config.

type RateLimitStats

type RateLimitStats struct {
	TotalHits stats.Counter
	OverLimit stats.Counter
	NearLimit stats.Counter
}

Stats for an individual rate limit config entry.

Jump to

Keyboard shortcuts

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