Files
sow-tools/internal/depot/backend.go
T
archvillainetteandClaude Fable 5 da59e54261 feat(depot): backend interface and local backend
Implement Backend interface with Probe/Get/Put methods, ProbeState constants,
and LocalBackend using filesystem storage with atomic operations and hash
verification.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-04 23:37:13 +02:00

25 lines
735 B
Go

package depot
import "context"
type ProbeState int
const (
Present ProbeState = iota
Absent
Unconfirmed
)
// Backend defines the interface for blob storage backends.
type Backend interface {
// Name returns the backend name.
Name() string
// Probe returns the existence state of one sha. transient=true means a
// retry might change the answer (feeds the serial confirm loop).
Probe(ctx context.Context, sha string) (state ProbeState, transient bool, err error)
// Get fetches sha into dest (temp file + rename), re-hashes, deletes on mismatch.
Get(ctx context.Context, sha, dest string) error
// Put uploads bytes from src for sha. Read-only backends return an error.
Put(ctx context.Context, sha, src string) error
}