Documentation
¶
Index ¶
- Variables
- type Local
- func (l *Local) Delete(_ context.Context, key string) error
- func (l *Local) Exists(_ context.Context, key string) (bool, error)
- func (l *Local) Get(_ context.Context, key string) (io.ReadCloser, int64, error)
- func (l *Local) List(ctx context.Context, fn func(ObjectInfo) error) error
- func (l *Local) Put(_ context.Context, r io.Reader) (Object, error)
- type Object
- type ObjectInfo
- type S3
- func (s *S3) Delete(ctx context.Context, key string) error
- func (s *S3) Exists(ctx context.Context, key string) (bool, error)
- func (s *S3) Get(ctx context.Context, key string) (io.ReadCloser, int64, error)
- func (s *S3) List(ctx context.Context, fn func(ObjectInfo) error) error
- func (s *S3) Put(ctx context.Context, r io.Reader) (Object, error)
- type S3Config
- type Storage
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidKey = errors.New("storage: invalid object key")
ErrInvalidKey is returned for a key that isn't a sha256 content address (64 lowercase hex chars). Backends check this before touching the filesystem or bucket so a bad key from a drifted DB row fails cleanly.
Functions ¶
This section is empty.
Types ¶
type Local ¶
type Local struct {
// contains filtered or unexported fields
}
Local stores objects on the local filesystem under root, sharded by the first two hex chars of the sha256 to keep directories small.
type Object ¶
type Object struct {
Key string // backend-defined; for Local it is the sha256 hex
Size int64
SHA256 string
}
Object is the metadata returned after writing to storage.
type ObjectInfo ¶
ObjectInfo describes a stored object as reported by List.
type S3 ¶
type S3 struct {
// contains filtered or unexported fields
}
S3 stores objects in an S3-compatible bucket, keyed by content sha256 (same content-addressing + dedup contract as Local). Durability is the bucket's responsibility — see PLAN.md ("Storage: do we need erasure coding?").
func NewS3 ¶
NewS3 builds the client and ensures the bucket exists. It retries the initial reach for ~30s so it tolerates being started alongside the S3 server (compose) before it is accepting connections.
type S3Config ¶
type S3Config struct {
Endpoint string // host:port, no scheme (e.g. "rustfs:9000")
AccessKey string
SecretKey string
Bucket string
UseSSL bool
}
S3Config configures the S3-backed Storage. Works against RustFS (compose), AWS S3, Cloudflare R2, Backblaze B2, SeaweedFS — anything S3-API-compatible. minio-go is used purely as a generic S3 client.
type Storage ¶
type Storage interface {
// Put streams r to storage, computing sha256 in flight, and deduplicates
// by content hash. Returns the resulting Object whose Key can be used
// with Get.
Put(ctx context.Context, r io.Reader) (Object, error)
// Get opens the object for key and reports its size in bytes, so callers
// can set a Content-Length that matches the bytes they're about to stream
// rather than trusting a separately-stored size that may have drifted.
// Returns fs.ErrNotExist if the key is absent. Get, Delete and Exists
// return ErrInvalidKey for a key that isn't a sha256 hex digest.
Get(ctx context.Context, key string) (io.ReadCloser, int64, error)
Delete(ctx context.Context, key string) error
Exists(ctx context.Context, key string) (bool, error)
// List calls fn for every stored object, in no particular order, stopping
// at the first error fn returns. Used by blob garbage collection.
List(ctx context.Context, fn func(ObjectInfo) error) error
}
Storage is a content-addressable blob interface. Implementations are responsible for durability — callers do not request replication or erasure-coding. See PLAN.md ("Storage: do we need erasure coding?").