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>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user