cache

package
v0.0.0-...-9febfc8 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2025 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Copyright 2023 The Chromium Authors Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CachingService

type CachingService string

CachingService represents a caching service.

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 NewEnv

func NewEnv(preferredCachingServices string, ufsClient ufsapi.FleetClient) (Environment, error)

NewEnv creates new instance of Environment according to inputs.

func NewPreferredEnv

func NewPreferredEnv(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 ufsapi.FleetClient) (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.

func (*Frontend) AssignBackend

func (f *Frontend) AssignBackend(dutName, filename string) (string, error)

AssignBackend assigns a healthy backend to the request from `dutName` on `filename`. This function is concurrency safe.

type Subnet

type Subnet struct {
	IPNet    *net.IPNet
	Backends []string
}

Subnet is a network in labs (i.e. test VLAN). DUTs can only access caching backends in the same Subnet.

Jump to

Keyboard shortcuts

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