storagefs

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package storagefs implements fs.Storage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ObjectRef added in v0.5.0

type ObjectRef struct {
	Bucket string
	Key    string
}

ObjectRef identifies an object by bucket and key.

type Option added in v0.5.0

type Option func(*Storage)

Option configures a Storage.

func WithSyncPolicy added in v0.5.0

func WithSyncPolicy(p SyncPolicy) Option

WithSyncPolicy sets the durability policy (default SyncNone).

func WithVerifyReads added in v0.5.0

func WithVerifyReads(v bool) Option

WithVerifyReads makes GetObject recompute and check each object's checksum before serving it, returning fs.ErrIntegrity on a mismatch so corrupt data is never served. Off by default: it costs a full extra read per GET.

type ScrubOptions added in v0.5.0

type ScrubOptions struct {
	// Quarantine moves each corrupt object (and its sidecar) into
	// <root>/.quarantine so it is no longer served. When false, corruption is
	// only reported.
	Quarantine bool
}

ScrubOptions configures a scrub pass.

type ScrubReport added in v0.5.0

type ScrubReport struct {
	// Scanned is the number of objects examined.
	Scanned int
	// OK is the number whose content matched its stored checksum.
	OK int
	// Corrupt lists objects whose content did not match (bit-rot).
	Corrupt []ObjectRef
	// Unverifiable is the number with no stored checksum to compare against
	// (e.g. pre-checksum data directories).
	Unverifiable int
	// Quarantined is the number of corrupt objects moved aside.
	Quarantined int
}

ScrubReport summarizes a scrub pass.

func (*ScrubReport) Healthy added in v0.5.0

func (r *ScrubReport) Healthy() bool

Healthy reports whether the pass found no corruption.

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

func New

func New(root string, opts ...Option) (*Storage, error)

func (*Storage) AbortMultipartUpload

func (s *Storage) AbortMultipartUpload(_ context.Context, _, _, uploadID string) error

func (*Storage) BucketACL added in v0.5.0

func (s *Storage) BucketACL(_ context.Context, bucket string) (fs.ACL, error)

func (*Storage) BucketExists

func (s *Storage) BucketExists(_ context.Context, bucket string) (bool, error)

func (*Storage) CreateBucket

func (s *Storage) CreateBucket(ctx context.Context, bucket string) error

func (*Storage) CreateMultipartUpload

func (s *Storage) CreateMultipartUpload(_ context.Context, req *fs.CreateMultipartUploadRequest) (*fs.MultipartUpload, error)

func (*Storage) DeleteBucket

func (s *Storage) DeleteBucket(ctx context.Context, bucket string) error

DeleteBucket deletes the specified bucket.

NB: bucket is already sanitized.

func (*Storage) DeleteObject

func (s *Storage) DeleteObject(ctx context.Context, bucket, key string) error

DeleteObject deletes the specified object from the bucket.

NB: bucket and key are already sanitized.

func (*Storage) DeleteObjectTagging added in v0.4.0

func (s *Storage) DeleteObjectTagging(_ context.Context, bucket, key string) error

func (*Storage) GetObject

func (s *Storage) GetObject(ctx context.Context, bucket, key string) (*fs.GetObjectResponse, error)

func (*Storage) GetObjectTagging added in v0.4.0

func (s *Storage) GetObjectTagging(_ context.Context, bucket, key string) ([]fs.Tag, error)

func (*Storage) ListBuckets

func (s *Storage) ListBuckets(ctx context.Context) ([]fs.Bucket, error)

func (*Storage) ListMultipartUploads added in v0.4.0

func (s *Storage) ListMultipartUploads(_ context.Context, bucket string) ([]fs.MultipartUpload, error)

func (*Storage) ListObjects

func (s *Storage) ListObjects(ctx context.Context, bucket, prefix string) ([]fs.Object, error)

ListObjects lists all objects in bucket by prefix.

NB: bucket and prefix are already sanitized.

func (*Storage) ListParts added in v0.4.0

func (s *Storage) ListParts(_ context.Context, bucket, key, uploadID string) ([]fs.Part, error)

func (*Storage) ObjectACL added in v0.5.0

func (s *Storage) ObjectACL(_ context.Context, bucket, key string) (fs.ACL, error)

func (*Storage) PutObject

func (s *Storage) PutObject(ctx context.Context, req *fs.PutObjectRequest) (*fs.PutObjectResponse, error)

func (*Storage) PutObjectTagging added in v0.4.0

func (s *Storage) PutObjectTagging(_ context.Context, bucket, key string, tags []fs.Tag) error

func (*Storage) Scrub added in v0.5.0

func (s *Storage) Scrub(ctx context.Context, opts ScrubOptions) (*ScrubReport, error)

Scrub walks every object, recomputing its MD5 and comparing to the stored content checksum, reporting (and optionally quarantining) any mismatch. It is safe to run concurrently with serving; it stops early if ctx is canceled.

func (*Storage) SetBucketACL added in v0.5.0

func (s *Storage) SetBucketACL(_ context.Context, bucket string, acl fs.ACL) error

func (*Storage) UploadPart

func (s *Storage) UploadPart(_ context.Context, req *fs.UploadPartRequest) (*fs.Part, error)

type SyncPolicy added in v0.5.0

type SyncPolicy int

SyncPolicy controls how aggressively storagefs flushes writes to stable storage. Atomicity (no torn object ever visible) comes from the temp-file + rename protocol regardless of policy; SyncPolicy governs durability — whether an acknowledged write survives a power loss.

const (
	// SyncNone performs no fsync. Fastest; an acked write may be lost on power
	// loss (never torn). The library/test default.
	SyncNone SyncPolicy = iota
	// SyncFile fsyncs file contents before the rename. The object's data is
	// durable once PutObject returns; the directory entry (the rename) relies on
	// the OS to persist it.
	SyncFile
	// SyncFileDir fsyncs file contents and the parent directory after the
	// rename, so both the data and its visibility survive a crash. The binary
	// default.
	SyncFileDir
)

func ParseSyncPolicy added in v0.5.0

func ParseSyncPolicy(s string) (SyncPolicy, error)

ParseSyncPolicy maps a config string to a SyncPolicy, defaulting unknown or empty values to SyncFileDir (the safe choice).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL