cache

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEndpointCache added in v1.0.0

func NewEndpointCache() *endpointCache

func NewServiceCache

func NewServiceCache() *serviceCache

func NewWaypointCache added in v1.0.0

func NewWaypointCache(serviceCache ServiceCache) *waypointCache

func NewWorkloadCache

func NewWorkloadCache() *cache

Types

type Endpoint added in v1.0.0

type Endpoint struct {
	ServiceId    uint32
	Prio         uint32
	BackendIndex uint32
}

TODO: use `EndpointKey` struct

type EndpointCache added in v1.0.0

type EndpointCache interface {
	List(uint32) map[uint32]Endpoint // Endpoint slice by ServiceId
	AddEndpointToService(ep Endpoint, serviceID uint32)
	// DeleteEndpoint delete a endpoint regardless of the priority
	DeleteEndpoint(workloadID, serviceID uint32)
	// DeleteEndpointWithPriority delete a endpoint with given priority
	DeleteEndpointWithPriority(serviceID, workloadID, prio uint32)
	// DeleteEndpointByServiceId delete all endpoints belong to a given service
	DeleteEndpointByServiceId(uint32)
}

type NetworkAddress

type NetworkAddress struct {
	Network string
	Address netip.Addr
}

type ServiceCache

type ServiceCache interface {
	List() []*workloadapi.Service
	AddOrUpdateService(svc *workloadapi.Service)
	DeleteService(resourceName string)
	GetService(resourceName string) *workloadapi.Service
	GetServiceByAddr(address NetworkAddress) *workloadapi.Service
}

type WaypointCache added in v1.0.0

type WaypointCache interface {
	// AddOrUpdateService add or update service in this cache, return true if the
	// service's waypoint doesn't need to be resolved or resolved successfully.
	AddOrUpdateService(svc *workloadapi.Service) bool
	DeleteService(resourceName string)
	// AddOrUpdateWorkload add or update workload in this cache, return true if the
	// workload's waypoint doesn't need to be resolved or resolved successfully.
	AddOrUpdateWorkload(workload *workloadapi.Workload) bool
	DeleteWorkload(uid string)

	// Refresh is used to process waypoint service.
	// If it is a newly added waypoint service, it returns a series of services and workloads that need to be updated
	// whose hostname type waypoint address should be converted to IP address type. These services and workloads were
	// processed earlier but the hostname of the related waypoint could not be resolved at that time.
	Refresh(svc *workloadapi.Service) ([]*workloadapi.Service, []*workloadapi.Workload)
}

type WorkloadCache

type WorkloadCache interface {
	GetWorkloadByUid(uid string) *workloadapi.Workload
	GetWorkloadByAddr(networkAddress NetworkAddress) *workloadapi.Workload
	AddOrUpdateWorkload(workload *workloadapi.Workload)
	DeleteWorkload(uid string)
	List() []*workloadapi.Workload
}

Jump to

Keyboard shortcuts

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