Documentation
¶
Overview ¶
Package limesrates contains data structures that appear on the Limes rate API.
Index ¶
- type ClusterRateReport
- type ClusterRateReports
- type ClusterReport
- type ClusterServiceReport
- type ClusterServiceReports
- type ProjectRateReport
- type ProjectRateReports
- type ProjectReport
- type ProjectServiceReport
- type ProjectServiceReports
- type RateInfo
- type RateLimitRequest
- type RateName
- type RateRequest
- type ServiceRequest
- type Window
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[RateName]*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[limes.ServiceType]*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[RateName]*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[limes.ServiceType]*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 ¶
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 ¶
RateLimitRequest contains new values for a single rate limit. It appears in type ServiceRequest.
type RateName ¶ added in v1.10.11
type RateName string
RateName identifies a rate within a service. This type is used to distinguish rate names from other types of string values in function signatures.
type RateRequest ¶
type RateRequest map[limes.ServiceType]ServiceRequest
RateRequest contains new rate limit values for rates in multiple services. 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[RateName]RateLimitRequest
ServiceQuotaRequest contains new rate limit values for rates in a single service. 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 ¶
MustParseWindow is like ParseWindow, but panics on error. This should only be used for compile-time constants.
func ParseWindow ¶
ParseWindow parses a string representation like "1s" or "5m".
func (Window) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (*Window) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.