cache

package
v0.0.0-...-020ad19 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WeightKind = "weight" // Key name in metadata where the weight is stored.
	LoadKind   = "load"   // Key name in the metadata where the load is stored.
	HashKind   = "hash"   // hash of the textpb cluster definition.
)

Variables

This section is empty.

Functions

func HashFromMetadata

func HashFromMetadata(cl *xdspb2.Cluster) string

HashFromMetada returns the hash from the metadata.

func LoadFromMetadata

func LoadFromMetadata(cl *xdspb2.Cluster, locality string) uint64

LoadFromMetada returns the load as reported in the metadata of the endpoint.

func SetHashInMetadata

func SetHashInMetadata(cl *xdspb2.Cluster, hash string)

SetHashInMetadata set the hash in the metadata.

func SetLoadInMetadata

func SetLoadInMetadata(cl *xdspb2.Cluster, locality string, load uint64)

SetLoadInMetadata adds load to the metadata of the LbEndpoint.

func SetWeightInMetadata

func SetWeightInMetadata(us *edspb2.UpstreamEndpointStats, weight uint32)

func TotalLoadFromMetadata

func TotalLoadFromMetadata(cl *xdspb2.Cluster) uint64

func WeightFromMetadata

func WeightFromMetadata(us *edspb2.UpstreamEndpointStats) uint32

WeightFromMetadata returns the weight from the metadata in the load report. If there is none, 0 is returned.

Types

type Cluster

type Cluster struct {
	// contains filtered or unexported fields
}

Clusters holds the current clusters. For each cluster we only keep the ClusterLoadAssignments, for ClusterType queries we will create a reply on-the-fly. We don't care about node-id's, but we do check the version of the incoming reply to see if we have a newer one.

func New

func New() *Cluster

func (*Cluster) All

func (c *Cluster) All() []string

All returns all cluster names in alphabetical order available in the cache.

func (*Cluster) Fetch

Fetch fetches cluster data from the cluster. Here we probably deviate from the spec, as empty versions are allowed and we will return the full list again. For versioning we use the highest version we see in the cache and use that as the version in the reply.

func (*Cluster) Insert

func (c *Cluster) Insert(ep *xdspb2.Cluster)

func (*Cluster) InsertWithoutVersionUpdate

func (c *Cluster) InsertWithoutVersionUpdate(ep *xdspb2.Cluster)

func (*Cluster) Retrieve

func (c *Cluster) Retrieve(name string) (*xdspb2.Cluster, uint64)

func (*Cluster) SetHealth

SetHealth sets the health for clusters and or endpoints.

func (*Cluster) SetLoad

SetLoad sets the load for clusters and or endpoints.

func (*Cluster) SetWeight

SetWeight sets the weight within cluster for endpoints.

func (*Cluster) Version

func (c *Cluster) Version() uint64

Version returns the version of the cluster.

type MarshaledResource

type MarshaledResource = []byte

func MarshalResource

func MarshalResource(resource proto.Message) (MarshaledResource, error)

MarshalResource converts the Resource to a MarshaledResource.

type Response

type Response struct {
	*xdspb2.DiscoveryResponse
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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