Documentation
¶
Overview ¶
Package cache provides functions to manage local cache of UFS data.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Environment ¶
type Environment interface { // Subnets returns the caching subnets. // The slice returned may be shared, so do not modify it. // This function is concurrency safe. Subnets() []Subnet // CacheZones returns the caching zones. // A caching zone is a series of caching services serving a UFS zone. // The map returned may be shared, so do not modify it. // This function is concurrency safe. CacheZones() map[ufsModels.Zone][]CachingService // GetZoneForServer returns UFS zone for the given server name. GetZoneForServer(name string) (ufsModels.Zone, error) // GetZoneForDUT returns UFS zone for the given DUT name. GetZoneForDUT(name string) (ufsModels.Zone, error) }
Environment is the runtime dependencies, e.g. networking, etc. of the implementation. The main goal of it is for unit test.
func New ¶
func New(ctx context.Context, ufsClient UFSClient) (Environment, error)
New creates new instance of Environment according to inputs.
func NewPreferredEnv ¶
func NewPreferredEnv(ctx context.Context, services string) (Environment, error)
NewPreferredEnv creates a new preferred caching service environment. In this environment, we skip further server selection based on either UFS zone or subnets.
func NewUFSEnv ¶
func NewUFSEnv(c UFSClient) (Environment, error)
NewUFSEnv creates an instance of Environment for caching services registered in UFS. It caches the result to prevent frequent access to UFS. It updates the cache regularly.
type Frontend ¶
type Frontend struct {
// contains filtered or unexported fields
}
Frontend manages caching backends and assigns backends for client requests.
func NewFrontend ¶
func NewFrontend(env Environment) *Frontend
NewFrontend creates a new cache frontend.
type Subnet ¶
Subnet is a network in labs (i.e. test VLAN). DUTs can only access caching backends in the same Subnet.
type UFSClient ¶
type UFSClient interface { GetMachineLSE(ctx context.Context, req *ufsapi.GetMachineLSERequest, opts ...grpc.CallOption) (*ufsModels.MachineLSE, error) GetMachine(ctx context.Context, req *ufsapi.GetMachineRequest, opts ...grpc.CallOption) (*ufsModels.Machine, error) ListCachingServices(ctx context.Context, req *ufsapi.ListCachingServicesRequest, opts ...grpc.CallOption) (*ufsapi.ListCachingServicesResponse, error) }