Documentation ¶
Overview ¶
Package storage implements a simple storage abstraction.
This is meant to abstract filesystem calls, as well as be a wrapper for in-memory or remote storage. It also provides a smaller attack vector as implementations can do verifications as to what is accessed and what is not.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrIncompleteWrite is the error returned if a write is not complete ErrIncompleteWrite = errors.New("incomplete write") // ErrClosed is the error returned if a bucket or object is already closed. ErrClosed = errors.New("already closed") )
Functions ¶
func IsNotExist ¶
IsNotExist returns true for a Error that is for a path not existing.
func NewErrNotExist ¶
func NewErrNotExist(path string) *storagepath.Error
NewErrNotExist returns a new Error for a path not existing.
Types ¶
type BucketInfo ¶ added in v0.9.0
type BucketInfo interface { // InMemory returns true if the bucket is in memory. InMemory() bool }
BucketInfo contains bucket info.
type ObjectInfo ¶
type ObjectInfo interface { // Size is the size of the object. // // For writes, the write size must sum up to this size when closed, otherwise ErrIncompleteWrite is returned. // For writes, any write over this size will return io.EOF. Size() uint32 }
ObjectInfo contains object info.
type ReadBucket ¶
type ReadBucket interface { // Get gets the path. // // Returns ErrNotExist if the path does not exist, other error // if there is a system error. Get(ctx context.Context, path string) (ReadObject, error) // Stat gets info in the object. // // Returns ErrNotExist if the path does not exist, other error // if there is a system error. Stat(ctx context.Context, path string) (ObjectInfo, error) // Walk walks the bucket with the prefix, calling f on each path. // // Note that foo/barbaz will not be called for foo/bar, but will // be called for foo/bar/baz. // // All paths given to f are normalized and validated. // If f returns error, Walk will stop short and return this error. // Returns other error on system error. Walk(ctx context.Context, prefix string, f func(string) error) error Info() BucketInfo }
ReadBucket is a simple read-only bucket.
All paths regular files - Buckets do not handle directories. All paths must be relative. All paths are cleaned and ToSlash'ed by each function. Paths must not jump the bucket context, that is after clean, they cannot contain "..".
type ReadBucketCloser ¶ added in v0.9.0
type ReadBucketCloser interface { io.Closer ReadBucket }
ReadBucketCloser is a read-only bucket that must be closed.
type ReadObject ¶
type ReadObject interface { io.ReadCloser Info() ObjectInfo }
ReadObject is a read-only object.
It must be closed when done.
type ReadWriteBucket ¶ added in v0.9.0
type ReadWriteBucket interface { ReadBucket // Put returns a WriteCloser to write to the path. // // The path is truncated beforehand. // // Returns error on system error. Put(ctx context.Context, path string, size uint32) (WriteObject, error) }
ReadWriteBucket is a simple read/write bucket.
type ReadWriteBucketCloser ¶ added in v0.9.0
type ReadWriteBucketCloser interface { io.Closer ReadWriteBucket }
ReadWriteBucketCloser is a read/write bucket that must be closed.
type WriteObject ¶
type WriteObject interface { io.WriteCloser Info() ObjectInfo }
WriteObject is a write-only object.
It must be closed when done.
Directories ¶
Path | Synopsis |
---|---|
storagetesting
Package storagetesting implements all testing for the storage packages.
|
Package storagetesting implements all testing for the storage packages. |
Package storagegit implements git utilities.
|
Package storagegit implements git utilities. |
Package storagemem implements an in-memory storage Bucket.
|
Package storagemem implements an in-memory storage Bucket. |
Package storageos implements an os-backed storage Bucket.
|
Package storageos implements an os-backed storage Bucket. |
Package storagepath provides functions similar to filepath.
|
Package storagepath provides functions similar to filepath. |
Package storageutil implements storage utilities.
|
Package storageutil implements storage utilities. |