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 ¶
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.
Click to show internal directories.
Click to hide internal directories.