Package load provides functionality to record and maintain load data.



This section is empty.


This section is empty.


This section is empty.


type Data

type Data struct {
	// Cluster is the name of the cluster this data is for.
	Cluster string
	// Service is the name of the EDS service this data is for.
	Service string
	// TotalDrops is the total number of dropped requests.
	TotalDrops uint64
	// Drops is the number of dropped requests per category.
	Drops map[string]uint64
	// LocalityStats contains load reports per locality.
	LocalityStats map[string]LocalityData
	// ReportInternal is the duration since last time load was reported (stats()
	// was called).
	ReportInterval time.Duration

Data contains all load data reported to the Store since the most recent call to stats().

type LocalityData

type LocalityData struct {
	// RequestStats contains counts of requests made to the locality.
	RequestStats RequestData
	// LoadStats contains server load data for requests made to the locality,
	// indexed by the load type.
	LoadStats map[string]ServerLoadData

LocalityData contains load data for a single locality.

type PerClusterReporter

type PerClusterReporter interface {
	CallStarted(locality string)
	CallFinished(locality string, err error)
	CallServerLoad(locality, name string, val float64)
	CallDropped(category string)

PerClusterReporter wraps the methods from the loadStore that are used here.

type RequestData

type RequestData struct {
	// Succeeded is the number of succeeded requests.
	Succeeded uint64
	// Errored is the number of requests which ran into errors.
	Errored uint64
	// InProgress is the number of requests in flight.
	InProgress uint64

RequestData contains request counts.

type ServerLoadData

type ServerLoadData struct {
	// Count is the number of load reports.
	Count uint64
	// Sum is the total value of all load reports.
	Sum float64

ServerLoadData contains server load data.

type Store

type Store struct {
	// contains filtered or unexported fields

Store keeps the loads for multiple clusters and services to be reported via LRS. It contains loads to reported to one LRS server. Create multiple stores for multiple servers.

It is safe for concurrent use.

func NewStore

func NewStore() *Store

NewStore creates a Store.

func (*Store) PerCluster

func (s *Store) PerCluster(clusterName, serviceName string) PerClusterReporter

PerCluster returns the perClusterStore for the given clusterName + serviceName.

func (*Store) Stats

func (s *Store) Stats(clusterNames []string) []*Data

Stats returns the load data for the given cluster names. Data is returned in a slice with no specific order.

If no clusterName is given (an empty slice), all data for all known clusters is returned.

If a cluster's Data is empty (no load to report), it's not appended to the returned slice.