Documentation ¶
Overview ¶
Package sharded implements common support for sharded blob providers, such as filesystem or webdav.
Package sharded implements common support for sharded blob providers, such as filesystem or webdav.
Index ¶
- Constants
- type Impl
- type Options
- type Parameters
- type PrefixAndShards
- type Storage
- func (s *Storage) DeleteBlob(ctx context.Context, blobID blob.ID) error
- func (s *Storage) GetBlob(ctx context.Context, blobID blob.ID, offset, length int64, ...) error
- func (s *Storage) GetMetadata(ctx context.Context, blobID blob.ID) (blob.Metadata, error)
- func (s *Storage) GetShardedPathAndFilePath(ctx context.Context, blobID blob.ID) (shardPath, filePath string, err error)
- func (s *Storage) ListBlobs(ctx context.Context, prefix blob.ID, callback func(blob.Metadata) error) error
- func (s *Storage) PutBlob(ctx context.Context, blobID blob.ID, data blob.Bytes, opts blob.PutOptions) error
Constants ¶
const CompleteBlobSuffix = ".f"
CompleteBlobSuffix is the extension for sharded blobs that have completed writing.
const ParametersFile = ".shards"
ParametersFile is the name of the hidden parameters file in a sharded storage.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Impl ¶
type Impl interface { GetBlobFromPath(ctx context.Context, dirPath, filePath string, offset, length int64, output blob.OutputBuffer) error GetMetadataFromPath(ctx context.Context, dirPath, filePath string) (blob.Metadata, error) PutBlobInPath(ctx context.Context, dirPath, filePath string, dataSlices blob.Bytes, opts blob.PutOptions) error DeleteBlobInPath(ctx context.Context, dirPath, filePath string) error ReadDir(ctx context.Context, path string) ([]os.FileInfo, error) }
Impl must be implemented by underlying provided.
type Options ¶ added in v0.9.6
type Options struct { DirectoryShards []int `json:"dirShards"` ListParallelism int `json:"listParallelism,omitempty"` }
Options must be anonymously embedded in sharded provider options.
type Parameters ¶ added in v0.9.0
type Parameters struct { DefaultShards []int `json:"default"` UnshardedLength int `json:"maxNonShardedLength"` Overrides []PrefixAndShards `json:"overrides,omitempty"` }
Parameters contains sharded storage configuration optionally persisted in the storage itself.
func DefaultParameters ¶ added in v0.9.0
func DefaultParameters(shards []int) *Parameters
DefaultParameters constructs Parameters based on the provided shards specification.
func (*Parameters) Clone ¶ added in v0.9.0
func (p *Parameters) Clone() *Parameters
Clone returns a clone of sharding parameters.
func (*Parameters) GetShardDirectoryAndBlob ¶ added in v0.9.0
GetShardDirectoryAndBlob gets that sharded directory and blob ID for a provided blob.
type PrefixAndShards ¶ added in v0.9.0
PrefixAndShards defines shards to use for a particular blob ID prefix.
type Storage ¶
Storage provides common implementation of sharded storage.
func (*Storage) DeleteBlob ¶
DeleteBlob implements blob.Storage.
func (*Storage) GetBlob ¶
func (s *Storage) GetBlob(ctx context.Context, blobID blob.ID, offset, length int64, output blob.OutputBuffer) error
GetBlob implements blob.Storage.
func (*Storage) GetMetadata ¶ added in v0.6.0
GetMetadata implements blob.Storage.
func (*Storage) GetShardedPathAndFilePath ¶
func (s *Storage) GetShardedPathAndFilePath(ctx context.Context, blobID blob.ID) (shardPath, filePath string, err error)
GetShardedPathAndFilePath returns the path of the shard and file name within the shard for a given blob ID.