Files
hakurei/internal/pkg/file.go
Ophestra f712466714
All checks were successful
Test / Create distribution (push) Successful in 47s
Test / Sandbox (push) Successful in 2m50s
Test / ShareFS (push) Successful in 4m46s
Test / Sandbox (race detector) (push) Successful in 5m16s
Test / Hpkg (push) Successful in 5m24s
Test / Hakurei (push) Successful in 5m40s
Test / Hakurei (race detector) (push) Successful in 7m27s
Test / Flake checks (push) Successful in 1m42s
internal/pkg: move dependency flooding to cache
This imposes a hard upper limit to concurrency during dependency satisfaction and moves all dependency-related code out of individual implementations of Artifact. This change also includes ctx and msg as part of Cache.

Signed-off-by: Ophestra <cat@gensokyo.uk>
2026-01-09 05:20:34 +09:00

35 lines
954 B
Go

package pkg
import (
"crypto/sha512"
)
// A fileArtifact is an [Artifact] that cures into data known ahead of time.
type fileArtifact []byte
var _ KnownChecksum = fileArtifact{}
// NewFile returns a [File] that cures into a caller-supplied byte slice.
//
// Caller must not modify data after NewBin returns.
func NewFile(data []byte) File { return fileArtifact(data) }
// Kind returns the hardcoded [Kind] constant.
func (a fileArtifact) Kind() Kind { return KindFile }
// Params returns the result of Data.
func (a fileArtifact) Params() []byte { return a }
// Dependencies returns a nil slice.
func (a fileArtifact) Dependencies() []Artifact { return nil }
// Checksum computes and returns the checksum of caller-supplied data.
func (a fileArtifact) Checksum() Checksum {
h := sha512.New384()
h.Write(a)
return Checksum(h.Sum(nil))
}
// Cure returns the caller-supplied data.
func (a fileArtifact) Cure() ([]byte, error) { return a, nil }