internal/pkg: optionally exempt implementations from cures counter
Test / Create distribution (push) Successful in 51s
Test / Sandbox (push) Successful in 2m49s
Test / ShareFS (push) Successful in 3m48s
Test / Hakurei (push) Successful in 3m59s
Test / Sandbox (race detector) (push) Successful in 5m23s
Test / Hakurei (race detector) (push) Successful in 6m39s
Test / Flake checks (push) Successful in 1m26s
Test / Create distribution (push) Successful in 51s
Test / Sandbox (push) Successful in 2m49s
Test / ShareFS (push) Successful in 3m48s
Test / Hakurei (push) Successful in 3m59s
Test / Sandbox (race detector) (push) Successful in 5m23s
Test / Hakurei (race detector) (push) Successful in 6m39s
Test / Flake checks (push) Successful in 1m26s
This avoids holding up many slots with a long pipeline. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -278,6 +278,8 @@ type archiveArtifact struct {
|
||||
f Artifact
|
||||
}
|
||||
|
||||
var _ CuresExempt = archiveArtifact{}
|
||||
|
||||
// NewArchive returns a new [Artifact] backed by the supplied [Artifact]. The
|
||||
// source [Artifact] must be a [FileArtifact] and produce a stream compatible
|
||||
// with [Reader].
|
||||
@@ -403,3 +405,7 @@ func (a archiveArtifact) Cure(t *TContext) (err error) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// CuresExempt exempts the cheap [KindArchive] implementation often found at
|
||||
// the end of a [FileArtifact] pipeline.
|
||||
func (archiveArtifact) CuresExempt() {}
|
||||
|
||||
@@ -25,6 +25,7 @@ type decompressArtifact struct {
|
||||
}
|
||||
|
||||
var _ FileArtifact = new(decompressArtifact)
|
||||
var _ CuresExempt = new(decompressArtifact)
|
||||
|
||||
// decompressArtifactNamed embeds decompressArtifact for a [fmt.Stringer] stream.
|
||||
type decompressArtifactNamed struct {
|
||||
@@ -117,3 +118,7 @@ func (a *decompressArtifact) Cure(r *RContext) (io.ReadCloser, error) {
|
||||
return nil, os.ErrInvalid
|
||||
}
|
||||
}
|
||||
|
||||
// CuresExempt exempts the cheap [KindDecompress] implementation often part of
|
||||
// a [FileArtifact] pipeline.
|
||||
func (*decompressArtifact) CuresExempt() {}
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
type fileArtifact []byte
|
||||
|
||||
var _ KnownChecksum = new(fileArtifact)
|
||||
var _ CuresExempt = new(fileArtifact)
|
||||
|
||||
// fileArtifactNamed embeds fileArtifact alongside a caller-supplied name.
|
||||
type fileArtifactNamed struct {
|
||||
@@ -79,3 +80,6 @@ func (a *fileArtifact) Checksum() Checksum {
|
||||
func (a *fileArtifact) Cure(*RContext) (io.ReadCloser, error) {
|
||||
return io.NopCloser(bytes.NewReader(*a)), nil
|
||||
}
|
||||
|
||||
// CuresExempt exempts the cheap [KindFile] implementation.
|
||||
func (*fileArtifact) CuresExempt() {}
|
||||
|
||||
@@ -485,6 +485,16 @@ type KnownChecksum interface {
|
||||
Checksum() Checksum
|
||||
}
|
||||
|
||||
// CuresExempt is optionally implemented for an artifact exempt to the
|
||||
// cache-wide cures counter and limit.
|
||||
type CuresExempt interface {
|
||||
Artifact
|
||||
|
||||
// CuresExempt is a no-op function but serves to distinguish implementations
|
||||
// that are cures-exempt.
|
||||
CuresExempt()
|
||||
}
|
||||
|
||||
// FileArtifact refers to an [Artifact] backed by a single file.
|
||||
//
|
||||
// FileArtifact does not support fine-grained cancellation. Its context is
|
||||
@@ -1892,6 +1902,10 @@ func (c *Cache) cure(a Artifact, curesExempt bool) (
|
||||
}
|
||||
}()
|
||||
|
||||
if _, ok := a.(CuresExempt); ok {
|
||||
curesExempt = true
|
||||
}
|
||||
|
||||
var (
|
||||
ctx context.Context
|
||||
done chan<- struct{}
|
||||
|
||||
@@ -16,6 +16,8 @@ type tarArtifact struct {
|
||||
f Artifact
|
||||
}
|
||||
|
||||
var _ CuresExempt = new(tarArtifact)
|
||||
|
||||
// tarArtifactNamed embeds tarArtifact for a [fmt.Stringer] tarball.
|
||||
type tarArtifactNamed struct {
|
||||
tarArtifact
|
||||
@@ -211,3 +213,7 @@ func (a *tarArtifact) Cure(t *TContext) (err error) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// CuresExempt exempts the cheap [KindTar] implementation often at the end of a
|
||||
// [FileArtifact] pipeline.
|
||||
func (*tarArtifact) CuresExempt() {}
|
||||
|
||||
Reference in New Issue
Block a user