limesrates

package
v1.10.2 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2023 License: Apache-2.0 Imports: 7 Imported by: 4

Documentation

Overview

Package limesrates contains data structures that appear on the Limes rate API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterRateReport

type ClusterRateReport struct {
	RateInfo
	Limit  uint64 `json:"limit,omitempty"`
	Window Window `json:"window,omitempty"`
}

ClusterRateReport is a substructure of ClusterServiceReport containing data for a single rate.

type ClusterRateReports

type ClusterRateReports map[string]*ClusterRateReport

ClusterRateReports provides fast lookup of rates using a map, but serializes to JSON as a list.

func (ClusterRateReports) MarshalJSON

func (r ClusterRateReports) MarshalJSON() ([]byte, error)

func (*ClusterRateReports) UnmarshalJSON

func (r *ClusterRateReports) UnmarshalJSON(buf []byte) error

type ClusterReport

type ClusterReport struct {
	limes.ClusterInfo
	Services ClusterServiceReports `json:"services"`
}

ClusterReport contains aggregated data about resource usage in a cluster. It is returned by GET endpoints for clusters.

type ClusterServiceReport

type ClusterServiceReport struct {
	limes.ServiceInfo
	Rates        ClusterRateReports     `json:"rates,omitempty"`
	MaxScrapedAt *limes.UnixEncodedTime `json:"max_scraped_at,omitempty"`
	MinScrapedAt *limes.UnixEncodedTime `json:"min_scraped_at,omitempty"`
}

ClusterServiceReport is a substructure of ClusterReport containing data for a single backend service.

type ClusterServiceReports

type ClusterServiceReports map[string]*ClusterServiceReport

ClusterServiceReports provides fast lookup of services by service type, but serializes to JSON as a list.

func (ClusterServiceReports) MarshalJSON

func (s ClusterServiceReports) MarshalJSON() ([]byte, error)

func (*ClusterServiceReports) UnmarshalJSON

func (s *ClusterServiceReports) UnmarshalJSON(buf []byte) error

type ProjectRateReport

type ProjectRateReport struct {
	RateInfo
	//NOTE: Both Window fields must have pointer types because omitempty does not
	//work directly on json.Marshaler-implementing types.
	Limit         uint64  `json:"limit,omitempty"`
	Window        *Window `json:"window,omitempty"`
	DefaultLimit  uint64  `json:"default_limit,omitempty"`
	DefaultWindow *Window `json:"default_window,omitempty"`
	UsageAsBigint string  `json:"usage_as_bigint,omitempty"`
}

ProjectRateReport is a substructure of ProjectServiceReport containing data for a single rate.

type ProjectRateReports

type ProjectRateReports map[string]*ProjectRateReport

ProjectRateReports provides fast lookup of rates using a map, but serializes to JSON as a list.

func (ProjectRateReports) MarshalJSON

func (r ProjectRateReports) MarshalJSON() ([]byte, error)

func (*ProjectRateReports) UnmarshalJSON

func (r *ProjectRateReports) UnmarshalJSON(buf []byte) error

type ProjectReport

type ProjectReport struct {
	limes.ProjectInfo
	Services ProjectServiceReports `json:"services"`
}

ProjectReport contains all data about resource usage in a project.

type ProjectServiceReport

type ProjectServiceReport struct {
	limes.ServiceInfo
	Rates     ProjectRateReports     `json:"rates,omitempty"`
	ScrapedAt *limes.UnixEncodedTime `json:"scraped_at,omitempty"`
}

ProjectServiceReport is a substructure of ProjectReport containing data for a single backend service.

type ProjectServiceReports

type ProjectServiceReports map[string]*ProjectServiceReport

ProjectServiceReports provides fast lookup of services using a map, but serializes to JSON as a list.

func (ProjectServiceReports) MarshalJSON

func (s ProjectServiceReports) MarshalJSON() ([]byte, error)

func (*ProjectServiceReports) UnmarshalJSON

func (s *ProjectServiceReports) UnmarshalJSON(buf []byte) error

type RateInfo

type RateInfo struct {
	Name string     `json:"name"`
	Unit limes.Unit `json:"unit,omitempty"`
}

RateInfo contains the metadata for a rate (i.e. some type of event that can be rate-limited and for which there may a way to retrieve a count of past events from a backend service).

type RateLimitRequest

type RateLimitRequest struct {
	Limit  uint64
	Window Window
}

RateLimitRequest contains new values for a single rate limit. It appears in type ServiceRequest.

type RateRequest

type RateRequest map[string]ServiceRequest

RateRequest contains new rate limit values for rates in multiple services. The map key is the service type. This type is used to serialize JSON request bodies in PUT requests on projects.

func (RateRequest) MarshalJSON

func (r RateRequest) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*RateRequest) UnmarshalJSON

func (r *RateRequest) UnmarshalJSON(input []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type ServiceRequest

type ServiceRequest map[string]RateLimitRequest

ServiceQuotaRequest contains new rate limit values for rates in a single service. The map key is the rate name. This type appears in type RateRequest.

type Window

type Window uint64

Window is the size (in nanoseconds) of the time window that is considered when enforcing a rate limit. For example, a rate limit of "10 per second" has a limit of 10 and a window of 1 second.

This type is very similar to time.Duration, but does not allow negative values and uses a different parsing logic that does not allow phrases with multiple units like time.Duration does (e.g. "2h30m").

const (
	//WindowMilliseconds is a Window unit.
	WindowMilliseconds Window = 1000 * 1000
	//WindowSeconds is a Window unit.
	WindowSeconds Window = 1000 * WindowMilliseconds
	//WindowMinutes is a Window unit.
	WindowMinutes Window = 60 * WindowSeconds
	//WindowHours is a Window unit.
	WindowHours Window = 60 * WindowMinutes
)

func MustParseWindow

func MustParseWindow(input string) Window

MustParseWindow is like ParseWindow, but panics on error. This should only be used for compile-time constants.

func ParseWindow

func ParseWindow(input string) (Window, error)

ParseWindow parses a string representation like "1s" or "5m".

func (Window) MarshalJSON

func (w Window) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (Window) String

func (w Window) String() string

String returns the optimal string representation for this window.

func (*Window) UnmarshalJSON

func (w *Window) UnmarshalJSON(buf []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*Window) UnmarshalYAML

func (w *Window) UnmarshalYAML(unmarshal func(any) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface. This method validates that windows in the config file are valid.

Jump to

Keyboard shortcuts

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