remotecache

package
v1.0.0-beta.16 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package remotecache connects an engine to the remote cache service. Run keeps one WebSocket open to the service, answers its requests through the engine's Adapter, and asks it for fresh download addresses when a read of an offered part needs one. The engine serves from its first second whether or not the connection is up, and Run never waits on the service to return.

Index

Constants

View Source
const (
	// ExportsInFlight is how many exports the engine works on at once.
	ExportsInFlight = 4
	// UploadConcurrency is how many blobs the engine uploads at once, across
	// all its exports.
	UploadConcurrency = 8
)

The engine side's limits.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, adapter Adapter, cfg Config) error

Run keeps the engine connected to the service until ctx is cancelled, and then returns nil promptly: it closes the connection without waiting for the service, cancels uploads, and releases the chains held for exports.

Types

type Adapter

type Adapter interface {
	// CacheIdentity returns the engine cache's identity and generation.
	CacheIdentity() (cacheID string, generation uint64)
	// Export captures the requested roots and calls consume exactly once,
	// while the captured chains stay open. The export's Bundle is nil when no
	// root survived. The chains are released when consume returns.
	Export(ctx context.Context, req protocol.Export, consume func(context.Context, Export) error) error
	// Merge merges a bundle of the service's values into the cache.
	Merge(ctx context.Context, req protocol.Merge) (protocol.Merged, error)
	// OfferParts places offered parts on the cache's entries by number.
	OfferParts(ctx context.Context, req protocol.Offer) (protocol.Offered, error)
	// TakeRenewalRequest waits for the next read that needs fresh download
	// addresses; ReplyRenewal answers it.
	TakeRenewalRequest(ctx context.Context) (*dagql.RenewalRequest, error)
	ReplyRenewal(dagql.RenewalReply) dagql.RenewalReplyDisposition
}

Adapter is the engine's side of the service's requests: its cache operations by entry number, and the renewal mailbox.

type BlobSource

type BlobSource interface {
	ReadBlob(ctx context.Context, dgst digest.Digest) (io.ReadCloser, int64, error)
}

BlobSource reads a layer blob of an export's chains.

type Config

type Config struct {
	// URL is the service's base URL; Run dials protocol.EnginePath under it.
	URL string
	// Token is the engine token, sent as the Basic username.
	Token string
	// EngineVersion and EngineName are sent in hello.
	EngineVersion string
	EngineName    string
	// Logger receives the connection's warnings and errors. Nil discards.
	Logger *slog.Logger
}

Config configures Run.

type Export

type Export struct {
	// Bundle is nil when no root survived.
	Bundle  *dagql.ValueBundle
	Skipped []protocol.SkippedRoot
	// Blobs reads the bundle's layer blobs for upload.
	Blobs BlobSource
}

Export is one capture, as Adapter.Export hands it to its consumer.

Directories

Path Synopsis
Package protocol defines the messages an engine and the remote cache service exchange over one WebSocket.
Package protocol defines the messages an engine and the remote cache service exchange over one WebSocket.

Jump to

Keyboard shortcuts

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