grpc: Index | Files

package load

import ""

Package load provides functionality to record and maintain load data.


Package Files

reporter.go store.go

type Data Uses

type Data struct {
    // 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

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

type LocalityData Uses

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 Uses

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 PerClusterStore Uses

type PerClusterStore struct {
    // contains filtered or unexported fields

PerClusterStore is a repository for LB policy implementations to report store load data. It is safe for concurrent use.

TODO(easwars): Use regular maps with mutexes instead of sync.Map here. The latter is optimized for two common use cases: (1) when the entry for a given key is only ever written once but read many times, as in caches that only grow, or (2) when multiple goroutines read, write, and overwrite entries for disjoint sets of keys. In these two cases, use of a Map may significantly reduce lock contention compared to a Go map paired with a separate Mutex or RWMutex. Neither of these conditions are met here, and we should transition to a regular map with a mutex for better type safety.

func (*PerClusterStore) CallDropped Uses

func (ls *PerClusterStore) CallDropped(category string)

CallDropped adds one drop record with the given category to store.

func (*PerClusterStore) CallFinished Uses

func (ls *PerClusterStore) CallFinished(locality string, err error)

CallFinished adds one call finished record for the given locality. For successful calls, err needs to be nil.

func (*PerClusterStore) CallServerLoad Uses

func (ls *PerClusterStore) CallServerLoad(locality, name string, d float64)

CallServerLoad adds one server load record for the given locality. The load type is specified by desc, and its value by val.

func (*PerClusterStore) CallStarted Uses

func (ls *PerClusterStore) CallStarted(locality string)

CallStarted adds one call started record for the given locality.

func (*PerClusterStore) Stats Uses

func (ls *PerClusterStore) Stats() *Data

Stats returns and resets all loads reported to the store, except inProgress rpc counts.

type RequestData Uses

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 Uses

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 Uses

type Store struct {
    // contains filtered or unexported fields

Store keeps the loads for multiple clusters and services to be reported via LRS. It is safe for concurrent use.

func NewStore Uses

func NewStore() *Store

NewStore creates a Store.

func (*Store) PerCluster Uses

func (ls *Store) PerCluster(clusterName, serviceName string) *PerClusterStore

PerCluster returns the PerClusterStore for the given clusterName + serviceName.

Package load imports 2 packages (graph) and is imported by 7 packages. Updated 2020-09-24. Refresh now. Tools for package owners.