cache

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LocalCacheID = "local"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheKey

type CacheKey struct {
	ID      string
	Results []Result
}

type Config

type Config struct {
	ImportPeriod  time.Duration
	ExportPeriod  time.Duration
	ExportTimeout time.Duration
}

func (Config) String

func (c Config) String() string

type ExportRecord

type ExportRecord struct {
	Digest     digest.Digest // record digest
	CacheRefID string        // worker cache id
}

type GetCacheMountConfigRequest added in v0.5.2

type GetCacheMountConfigRequest struct{}

type GetCacheMountConfigResponse added in v0.5.2

type GetCacheMountConfigResponse struct {
	SyncedCacheMounts []SyncedCacheMountConfig
}

type GetCacheMountUploadURLRequest added in v0.5.2

type GetCacheMountUploadURLRequest struct {
	CacheName string
	Digest    digest.Digest
	Size      int64
}

type GetCacheMountUploadURLResponse added in v0.5.2

type GetCacheMountUploadURLResponse struct {
	URL     string
	Headers map[string]string
}

type GetConfigRequest

type GetConfigRequest struct {
	EngineID string
}

func (GetConfigRequest) String

func (r GetConfigRequest) String() string

type GetLayerDownloadURLRequest added in v0.5.2

type GetLayerDownloadURLRequest struct {
	Digest digest.Digest
}

type GetLayerDownloadURLResponse added in v0.5.2

type GetLayerDownloadURLResponse struct {
	URL string
}

type GetLayerUploadURLRequest added in v0.5.2

type GetLayerUploadURLRequest struct {
	Digest digest.Digest
}

type GetLayerUploadURLResponse added in v0.5.2

type GetLayerUploadURLResponse struct {
	URL     string
	Headers map[string]string
	Skip    bool
}
type Link struct {
	ID       string
	LinkedID string
	Input    int
	Digest   digest.Digest
	Selector digest.Digest
}

type Manager

type Manager interface {
	solver.CacheManager
	StartCacheMountSynchronization(context.Context) error
	ReleaseUnreferenced(context.Context) error
	Close(context.Context) error
}

func NewManager

func NewManager(ctx context.Context, managerConfig ManagerConfig) (Manager, error)

type ManagerConfig

type ManagerConfig struct {
	KeyStore     solver.CacheKeyStorage
	ResultStore  solver.CacheResultStorage
	Worker       worker.Worker
	MountManager *mounts.MountManager
	ServiceURL   string
	Token        string
	EngineID     string
}

type RecordLayers

type RecordLayers struct {
	RecordDigest digest.Digest
	Layers       []ocispecs.Descriptor
}

type Result

type Result struct {
	ID          string
	CreatedAt   time.Time
	Description string
}

type Service

type Service interface {
	// GetConfig returns configuration needed for the engine to push layer blobs
	GetConfig(context.Context, GetConfigRequest) (*Config, error)

	// UpdateCacheRecords informs the cache service of the current state of the cache metadata.
	// It returns a list of cache refs that should be prepared for export and pushed.
	UpdateCacheRecords(context.Context, UpdateCacheRecordsRequest) (*UpdateCacheRecordsResponse, error)

	// UpdateCacheLayers tells the cache service that layers for the given records have been
	// uploaded with the given digests.
	UpdateCacheLayers(context.Context, UpdateCacheLayersRequest) error

	// ImportCache returns a cache config that the engine can turn into cache manager.
	ImportCache(context.Context) (*remotecache.CacheConfig, error)

	// GetLayerDownloadURL returns a URL that the engine can use to download the layer blob. The URL
	// is only valid for a limited time so this API should only be called right as the layer is needed.
	GetLayerDownloadURL(context.Context, GetLayerDownloadURLRequest) (*GetLayerDownloadURLResponse, error)

	// GetLayerUploadURL returns a URL that the engine can use to upload the layer blob. The URL is only
	// valid for a limited time so this API should only be called right as the layer is to be uploaded.
	GetLayerUploadURL(context.Context, GetLayerUploadURLRequest) (*GetLayerUploadURLResponse, error)

	// GetCacheMountConfig returns a list of cache mounts that the engine should sync locally. It contains
	// metadata like digest+size plus a time-limited URL that the engine can use to download the cache mounts.
	GetCacheMountConfig(context.Context, GetCacheMountConfigRequest) (*GetCacheMountConfigResponse, error)

	// GetCacheMountUploadURL returns a URL that the engine can use to upload the cache mount blob. The URL is only
	// valid for a limited time so this API should only be called right as the cache mount is to be uploaded.
	GetCacheMountUploadURL(context.Context, GetCacheMountUploadURLRequest) (*GetCacheMountUploadURLResponse, error)
}

The process on export is as follows:

  • Engine gathers metadata for current state of its local cache and sends it to the cache service via UpdateCacheRecords
  • The cache service responds with a list of cache refs that should be exported, if any
  • The engine compresses those them into layers, pushes them and then updates the cache service on what the digests of the layers ended up being via UpdateCacheLayers

The process on import is as follows:

  • The engine asks for a cache config from the cache service via ImportCache. This cache config is the same format used by buildkit to create cache managers from remote caches.
  • The cache service responds with that cache config
  • The engine creates a cache manager from the cache config and plugs it into the combined cache manager with the actual local cache

For cache mounts, the process is:

  • At engine startup, GetCacheMountConfig is called and any cache mounts returned are synced locally to the corresponding cache mount. This happens before any clients can connect to ensure consistency. The cache mount is a compressed tarball of the cache mount contents.
  • At engine shutdown, those cache mounts are synced back to the cache service. GetCacheMountUploadURL is called to get a URL to upload to, which may or may not be the same as the original download URL.

type SyncedCacheMountConfig added in v0.5.2

type SyncedCacheMountConfig struct {
	Name      string
	Digest    digest.Digest
	Size      int64
	MediaType string
	URL       string
}

type UpdateCacheLayersRequest

type UpdateCacheLayersRequest struct {
	UpdatedRecords []RecordLayers
}

func (UpdateCacheLayersRequest) String

func (r UpdateCacheLayersRequest) String() string

type UpdateCacheRecordsRequest

type UpdateCacheRecordsRequest struct {
	CacheKeys []CacheKey
	Links     []Link
}

func (UpdateCacheRecordsRequest) String

func (r UpdateCacheRecordsRequest) String() string

type UpdateCacheRecordsResponse

type UpdateCacheRecordsResponse struct {
	// cache records that the engine should prepare layers for and push
	ExportRecords []ExportRecord
}

func (UpdateCacheRecordsResponse) String

Jump to

Keyboard shortcuts

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