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 PathError that is for a path not existing.
Types ¶
type Bucket ¶
type Bucket 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) }
Bucket is a simple read/write bucket.
type PathError ¶
PathError is a path error.
func NewErrNotExist ¶
NewErrNotExist returns a new PathError for a path not existing.
type ReadBucket ¶
type ReadBucket interface { io.Closer // Type returns the type of bucket. Type() string // 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 }
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 ReadObject ¶
type ReadObject interface { io.ReadCloser // Size is the size of the object. Size() uint32 }
ReadObject is a read-only object.
It must be closed when done.
type WriteObject ¶
type WriteObject interface { io.WriteCloser // Size is the size of the object. // // When closed, the writes must sum up to this size, otherwise ErrIncompleteWrite is returned. // Any writes over the size will return io.EOF. Size() uint32 }
WriteObject is a write-only object.
It must be closed when done.
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
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. |