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 }