aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-06-20 01:03:28 +0900
committerOphestra <cat@gensokyo.uk>2026-06-20 01:03:28 +0900
commita4fab678114b61c1c3473661577797ecf029514d (patch)
treef86f898d05cb3d5861f9c13a0ebe81a2c8a41bd1
parented5cdd38a40e0e121b8bc1c432bbb57ca584f798 (diff)
internal/pkg: optionally exempt implementations from cures counter
This avoids holding up many slots with a long pipeline. Signed-off-by: Ophestra <cat@gensokyo.uk>
-rw-r--r--internal/pkg/archive.go6
-rw-r--r--internal/pkg/compress.go5
-rw-r--r--internal/pkg/file.go4
-rw-r--r--internal/pkg/pkg.go14
-rw-r--r--internal/pkg/tar.go6
5 files changed, 35 insertions, 0 deletions
diff --git a/internal/pkg/archive.go b/internal/pkg/archive.go
index 9f1b42d9..a58221e2 100644
--- a/internal/pkg/archive.go
+++ b/internal/pkg/archive.go
@@ -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() {}
diff --git a/internal/pkg/compress.go b/internal/pkg/compress.go
index 6d69143b..838cd98a 100644
--- a/internal/pkg/compress.go
+++ b/internal/pkg/compress.go
@@ -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() {}
diff --git a/internal/pkg/file.go b/internal/pkg/file.go
index 149ca817..18b85b82 100644
--- a/internal/pkg/file.go
+++ b/internal/pkg/file.go
@@ -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() {}
diff --git a/internal/pkg/pkg.go b/internal/pkg/pkg.go
index 7b4c9637..f1e6279d 100644
--- a/internal/pkg/pkg.go
+++ b/internal/pkg/pkg.go
@@ -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{}
diff --git a/internal/pkg/tar.go b/internal/pkg/tar.go
index d8ce3b67..9173a976 100644
--- a/internal/pkg/tar.go
+++ b/internal/pkg/tar.go
@@ -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() {}