Files
mesh-host/internal/apply/kept_artifact.go
T
jschoubben 132b767043 H-A-150: forget only on the store's own answer, and on the apply's fetch too
A fetch nothing answered for (a bus or store that did not answer, a gateway
saying the store is away) proves nothing about the digest, so it is tried
again as before and the module is not held for it; only an answer of the
store's (a 404, bytes not of the digest) forgets the resolution. The apply's
fetch of a bundle meets the same wrong digest as the take-in's, so it tells
the composer too (apply.WithFetchFailed, set in the node agent's apply).

Builds: design 47 H H-A-150, H-A-146, G A-430a
2026-11-20 16:35:42 +01:00

50 lines
2.2 KiB
Go

package apply
import "context"
// The build the artifact store's holder keeps on a build node (novox/hq design 47, *The artifact store's holder takes its
// own new build even when its seat is the one broken*): the holder's program cannot be fetched from the store it serves, so
// its done build names the node that keeps it and the node-engine fetches it from there, through the build seat's verb.
// How is the caller's (a hook on the apply's context, as the files' link is); what apply does is use the bytes in place of
// the source's fetch, check them against the declared digest as every fetch is, and gate the module when they cannot be had.
// KeptFetch gives the bytes of the artifact a module's done build kept on a build node, by the artifact's digest
// ("sha256:" and 64 hex digits, as a declaration names it). kept is false when the module's build kept no such artifact:
// the artifact is then fetched from its source, as before. An error says the artifact is kept and could not be had.
type KeptFetch func(ctx context.Context, module, digest string) (body []byte, kept bool, err error)
type keptFetchKey struct{}
// WithKept is ctx carrying how a kept artifact is fetched.
func WithKept(ctx context.Context, f KeptFetch) context.Context {
if f == nil {
return ctx
}
return context.WithValue(ctx, keptFetchKey{}, f)
}
func keptFetchFrom(ctx context.Context) KeptFetch {
f, _ := ctx.Value(keptFetchKey{}).(KeptFetch)
return f
}
// FetchFailed is told the digest of an artifact the store answered for and that failed (an answer other than the bytes, or
// bytes not of the digest), and why: the node's composer then forgets the resolution that named it (design 47 H, the lead's
// answers H-A-146 and H-A-150). A fetch nothing answered for is never told.
type FetchFailed func(digest, why string)
type fetchFailedKey struct{}
// WithFetchFailed is ctx carrying whom an apply tells of a failed fetch.
func WithFetchFailed(ctx context.Context, f FetchFailed) context.Context {
if f == nil {
return ctx
}
return context.WithValue(ctx, fetchFailedKey{}, f)
}
func fetchFailedFrom(ctx context.Context) FetchFailed {
f, _ := ctx.Value(fetchFailedKey{}).(FetchFailed)
return f
}