coldstart

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package coldstart decides how an agent resolves a digest when its local cache misses and the DHT lookup did not return enough providers.

The mirror miss path invokes ChairResolver after a FindProviders call returns empty. Resolution is driven by the fixed set of Lease chairs: the requester ranks the chairs for the digest, asks the leading cohort to pull from the origin registry, and polls the DHT until one of them publishes. See chair.go for the cascade and the outcomes it can produce.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFailureShortCircuit reports that a chair returned a failure the
	// requester trusts enough to stop asking further chairs.
	ErrFailureShortCircuit = errors.New("coldstart: failure short-circuit")
	// ErrCooldownActive reports that the origin pull is in a transient
	// backoff window, so the requester should not pile on.
	ErrCooldownActive = errors.New("coldstart: transient cooldown active")
	// ErrExhausted fires when the cascade reaches its terminal state
	// without producing a provider (the chair ranking ran out, or
	// please_pull completed but the DHT poll timed out).
	ErrExhausted = errors.New("coldstart: cascade exhausted")
)

Sentinel errors. The mirror layer maps all of these to 5xx; tests distinguish them to validate which rule fired.

View Source
var ErrPrefetchInvalid = errors.New("coldstart: prefetch invalid arguments")

ErrPrefetchInvalid signals a programmer error in the prefetch call: registry or repository was empty, which would produce a malformed please_pull request.

View Source
var ErrPrefetchPartial = errors.New("coldstart: prefetch had per-puller failures")

ErrPrefetchPartial signals that at least one chair's please_pull failed. The other chairs were still asked to pull. Callers can errors.Is against this for retry or logging logic; prefetch is best-effort, so this is informational rather than fatal.

Functions

This section is empty.

Types

type ChairClaimer added in v0.7.0

type ChairClaimer interface {
	ClaimFailed(ctx context.Context, chair chairs.Chair) (chairs.Chair, bool, error)
}

type ChairOptions added in v0.7.0

type ChairOptions struct {
	Chairs    ChairSnapshotCache
	Discovery Discovery
	// PeerMetadata verifies DHT candidates before they can complete polling.
	PeerMetadata          ifaces.PeerMetadataDialer
	Coord                 ifaces.ChairCoordinator
	LocalPull             ifaces.LocalChairPullStarter
	Inflight              *inflight.Map
	SelfPeerID            ifaces.NodeID
	CurrentEpoch          func() int64
	InstallHolder         func(chairs.Holder) error
	Claimer               ChairClaimer
	Logger                *slog.Logger
	QueryTimeout          time.Duration
	PollManifest          time.Duration
	PollLayer             time.Duration
	APITimeout            time.Duration
	ChairCount            int
	SeedCount             int
	TrustedFailureClasses []ifaces.FailureClass
	// OnSeedRecruit reports one completed seed-recruitment pass: how many chairs
	// were selectable, how many were contacted, and how many accepted. contacted
	// above the effective scaled cohort means the resolver moved down the ranking,
	// which widens the set of nodes fetching from origin.
	OnSeedRecruit func(kind string, selectable, contacted, accepted int)
	// OnChairDispatch reports the outcome of one please_pull to one chair.
	// reason is "accepted" or why the chair did not count: "rpc_error" (no
	// usable reply inside QueryTimeout), "recently_failed", "stale_chair", or
	// "declined". Only rpc_error is invisible to the chair itself.
	OnChairDispatch func(kind, reason string)
	// OnChairCall times one please_pull attempt against a remote chair.
	// outcome separates a clean reply from "deadline" (QueryTimeout expired),
	// so a run can tell a binding deadline from slow transport: deadline
	// outcomes pile up at QueryTimeout, transport shows a long ok tail.
	OnChairCall func(kind, outcome string, seconds float64)
}

type ChairResolver added in v0.7.0

type ChairResolver struct {
	// contains filtered or unexported fields
}

func NewChairResolver added in v0.7.0

func NewChairResolver(opts ChairOptions) *ChairResolver

func (*ChairResolver) PrefetchManifestChildren added in v0.7.0

func (r *ChairResolver) PrefetchManifestChildren(ctx context.Context, _ digest.Digest, children []ChildDigest, registry, repository string) error

func (*ChairResolver) Resolve added in v0.7.0

func (r *ChairResolver) Resolve(ctx context.Context, d digest.Digest, kind ifaces.OriginRefKind, registry, repository string, expectedSize int64) (*Resolution, error)

type ChairSnapshotCache added in v0.7.0

type ChairSnapshotCache interface {
	Snapshot(ctx context.Context, epoch int64) (chairs.Snapshot, error)
	RefreshChair(ctx context.Context, id chairs.ID) (chairs.Chair, error)
}

type ChildDigest

type ChildDigest struct {
	Digest digest.Digest
	Kind   ifaces.OriginRefKind
}

ChildDigest is a manifest child paired with its kind. Config blobs and layer blobs are both pulled from /v2/<repo>/blobs/<digest> but are carried separately on the wire so per-kind metrics agree end-to-end across the please_pull boundary. internal/manifest's TypedChildren is the canonical producer of these values.

type Discovery

type Discovery interface {
	FindProviders(ctx context.Context, d digest.Digest) ([]ifaces.Provider, error)
	Health() float64
}

Discovery is the subset of the libp2p discovery host that the orchestrator needs. Kept narrow for ease of mocking.

type Resolution

type Resolution struct {
	// Providers are transfer endpoints (host:port) the caller should
	// fetch from, in priority order. Non-empty on success.
	Providers []ifaces.Provider
	// Outcome names which rule fired. Useful for tests and metrics.
	Outcome string
}

Resolution carries the orchestrator's verdict.

Jump to

Keyboard shortcuts

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