cache

package
v0.0.0-...-0c1943d Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetResourceName

func GetResourceName(res envoy_types.Resource) string

GetResourceName returns the resource name for a valid xDS response type.

func GetResponseType

func GetResponseType(typeURL string) types.ResponseType

GetResponseType returns the enumeration for a valid xDS type URL

func IndexResourcesByName

func IndexResourcesByName(items []types.ResourceWithTTL) map[string]types.ResourceWithTTL

IndexResourcesByName creates a map from the resource name to the resource.

func NewResources

func NewResources(version string, items []types.Resource) envoy_cache.Resources

NewResources creates a new resource group.

func NewResourcesWithTTL

func NewResourcesWithTTL(version string, items []types.ResourceWithTTL) envoy_cache.Resources

NewResourcesWithTTL creates a new resource group.

Types

type IDHash

type IDHash struct{}

IDHash uses ID field as the node hash.

func (IDHash) ID

func (IDHash) ID(node *core.Node) string

ID uses the node ID field

type NodeHash

type NodeHash interface {
	// ID function defines a unique string identifier for the remote Envoy node.
	ID(node *core.Node) string
}

NodeHash computes string identifiers for Envoy nodes.

type Snapshot

type Snapshot struct {
	envoy_cache.Snapshot
	Resources [wso2_types.UnknownType]envoy_cache.Resources
	// Only used for delta XDS. Hence it remains unused for adapter implementation.
	VersionMap map[string]map[string]string
}

Snapshot is an internally consistent snapshot of xDS resources. Consistency is important for the convergence as different resource types from the snapshot may be delivered to the proxy in arbitrary order.

func NewSnapshot

func NewSnapshot(version string, resources map[resource.Type][]types.Resource) (Snapshot, error)

NewSnapshot creates a snapshot from response types and a version. The resources map is keyed off the type URL of a resource, followed by the slice of resource objects.

func (*Snapshot) GetResourcesAndTTL

func (s *Snapshot) GetResourcesAndTTL(typeURL resource.Type) map[string]types.ResourceWithTTL

GetResourcesAndTTL selects snapshot resources by type, returning the map of resources and the associated TTL.

func (*Snapshot) GetVersion

func (s *Snapshot) GetVersion(typeURL string) string

GetVersion returns the version for a resource type.

type SnapshotCache

type SnapshotCache interface {
	envoy_cache.Cache

	// SetSnapshot sets a response snapshot for a node. For ADS, the snapshots
	// should have distinct versions and be internally consistent (e.g. all
	// referenced resources must be included in the snapshot).
	//
	// This method will cause the server to respond to all open watches, for which
	// the version differs from the snapshot version.
	SetSnapshot(ctx context.Context, node string, snapshot Snapshot) error

	// GetSnapshots gets the snapshot for a node.
	GetSnapshot(node string) (Snapshot, error)

	// ClearSnapshot removes all status and snapshot information associated with a node.
	ClearSnapshot(node string)

	// GetStatusInfo retrieves status information for a node ID.
	GetStatusInfo(string) StatusInfo

	// GetStatusKeys retrieves node IDs for all statuses.
	GetStatusKeys() []string
}

SnapshotCache is a snapshot-based cache that maintains a single versioned snapshot of responses per node. SnapshotCache consistently replies with the latest snapshot. For the protocol to work correctly in ADS mode, EDS/RDS requests are responded only when all resources in the snapshot xDS response are named as part of the request. It is expected that the CDS response names all EDS clusters, and the LDS response names all RDS routes in a snapshot, to ensure that Envoy makes the request for all EDS clusters or RDS routes eventually.

SnapshotCache can operate as a REST or regular xDS backend. The snapshot can be partial, e.g. only include RDS or EDS resources.

func NewSnapshotCache

func NewSnapshotCache(ads bool, hash NodeHash, logger log.Logger) SnapshotCache

NewSnapshotCache initializes a simple cache.

ADS flag forces a delay in responding to streaming requests until all resources are explicitly named in the request. This avoids the problem of a partial request over a single stream for a subset of resources which would require generating a fresh version for acknowledgement. ADS flag requires snapshot consistency. For non-ADS case (and fetch), multiple partial requests are sent across multiple streams and re-using the snapshot version is OK.

Logger is optional.

func NewSnapshotCacheWithHeartbeating

func NewSnapshotCacheWithHeartbeating(ctx context.Context, ads bool, hash NodeHash, logger log.Logger, heartbeatInterval time.Duration) SnapshotCache

NewSnapshotCacheWithHeartbeating initializes a simple cache that sends periodic heartbeat responses for resources with a TTL.

ADS flag forces a delay in responding to streaming requests until all resources are explicitly named in the request. This avoids the problem of a partial request over a single stream for a subset of resources which would require generating a fresh version for acknowledgement. ADS flag requires snapshot consistency. For non-ADS case (and fetch), multiple partial requests are sent across multiple streams and re-using the snapshot version is OK.

Logger is optional.

The context provides a way to cancel the heartbeating routine, while the heartbeatInterval parameter controls how often heartbeating occurs.

Unused by the adapter at the moment.

type StatusInfo

type StatusInfo interface {
	// GetNode returns the node metadata.
	GetNode() *core.Node

	// GetNumWatches returns the number of open watches.
	GetNumWatches() int

	// GetNumDeltaWatches returns the number of open delta watches.
	GetNumDeltaWatches() int

	// GetLastWatchRequestTime returns the timestamp of the last discovery watch request.
	GetLastWatchRequestTime() time.Time

	// GetLastDeltaWatchRequestTime returns the timestamp of the last delta discovery watch request.
	GetLastDeltaWatchRequestTime() time.Time

	// SetLastDeltaWatchRequestTime will set the current time of the last delta discovery watch request
	SetLastDeltaWatchRequestTime(time.Time)

	// SetDeltaResponseWatch will set the provided delta response watch to the associate watch ID
	SetDeltaResponseWatch(int64, envoy_cache.DeltaResponseWatch)
}

StatusInfo tracks the server state for the remote Envoy node. Not all fields are used by all cache implementations.

Jump to

Keyboard shortcuts

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