package lrsclient

import "google.golang.org/grpc/xds/internal/clients/lrsclient"

Package lrsclient provides an LRS (Load Reporting Service) client.

See: https://www.envoyproxy.io/docs/envoy/latest/api-v3/service/load_stats/v3/lrs.proto

Index

Types

type Config

type Config struct {
	// Node is the identity of the client application reporting load to the
	// LRS server.
	Node clients.Node

	// TransportBuilder is used to connect to the LRS server.
	TransportBuilder clients.TransportBuilder
}

Config is used to configure an LRS client. After one has been passed to the LRS client's New function, no part of it may modified. A Config may be reused; the lrsclient package will also not modify it.

type LRSClient

type LRSClient struct {
}

LRSClient is an LRS (Load Reporting Service) client.

func New

func New(_ Config) (*LRSClient, error)

New returns a new LRS Client configured with the provided config.

func (*LRSClient) ReportLoad

func (*LRSClient) ReportLoad(_ clients.ServerIdentifier) *LoadStore

ReportLoad creates a new load reporting stream for the provided server. It creates and returns a LoadStore for the caller to report loads.

type LoadStore

type LoadStore struct {
}

A LoadStore aggregates loads for multiple clusters and services that are intended to be reported via LRS.

LoadStore stores loads reported to a single LRS server. Use multiple stores for multiple servers.

It is safe for concurrent use.

func (*LoadStore) ReporterForCluster

func (ls *LoadStore) ReporterForCluster(clusterName, serviceName string) PerClusterReporter

ReporterForCluster returns the PerClusterReporter for the given cluster and service.

func (*LoadStore) Stop

func (ls *LoadStore) Stop(ctx context.Context) error

Stop stops the LRS stream associated with this LoadStore.

If this LoadStore is the only one using the underlying LRS stream, the stream will be closed. If other LoadStores are also using the same stream, the reference count to the stream is decremented, and the stream remains open until all LoadStores have called Stop().

If this is the last LoadStore for the stream, this method makes a last attempt to flush any unreported load data to the LRS server. It will either wait for this attempt to complete, or for the provided context to be done before canceling the LRS stream.

type PerClusterReporter

type PerClusterReporter struct {
}

PerClusterReporter records load data pertaining to a single cluster. It provides methods to record call starts, finishes, server-reported loads, and dropped calls.

func (*PerClusterReporter) CallDropped

func (p *PerClusterReporter) CallDropped(category string)

CallDropped records a call dropped in the LoadStore.

func (*PerClusterReporter) CallFinished

func (p *PerClusterReporter) CallFinished(locality string, err error)

CallFinished records a call finished in the LoadStore.

func (*PerClusterReporter) CallServerLoad

func (p *PerClusterReporter) CallServerLoad(locality, name string, val float64)

CallServerLoad records the server load in the LoadStore.

func (*PerClusterReporter) CallStarted

func (p *PerClusterReporter) CallStarted(locality string)

CallStarted records a call started in the LoadStore.

Source Files

load_store.go lrsclient.go lrsconfig.go

Version
v1.72.0 (latest)
Published
Apr 21, 2025
Platform
linux/amd64
Imports
2 packages
Last checked
2 hours ago

Tools for package owners.