Documentation ¶
Index ¶
- Constants
- Variables
- type Compressor
- type DiskConfig
- type DiskStorage
- func (st *DiskStorage) Clean(ctx context.Context) error
- func (st *DiskStorage) Close() error
- func (st *DiskStorage) Filepath(key string) (string, error)
- func (st *DiskStorage) ReadBytes(ctx context.Context, key string) ([]byte, error)
- func (st *DiskStorage) ReadStream(ctx context.Context, key string) (io.ReadCloser, error)
- func (st *DiskStorage) Remove(ctx context.Context, key string) error
- func (st *DiskStorage) Stat(ctx context.Context, key string) (bool, error)
- func (st *DiskStorage) WalkKeys(ctx context.Context, opts WalkKeysOptions) error
- func (st *DiskStorage) WriteBytes(ctx context.Context, key string, value []byte) (int, error)
- func (st *DiskStorage) WriteStream(ctx context.Context, key string, r io.Reader) (int64, error)
- type Entry
- type KeyTransform
- type Lock
- type MemoryStorage
- func (st *MemoryStorage) Clean(ctx context.Context) error
- func (st *MemoryStorage) Close() error
- func (st *MemoryStorage) ReadBytes(ctx context.Context, key string) ([]byte, error)
- func (st *MemoryStorage) ReadStream(ctx context.Context, key string) (io.ReadCloser, error)
- func (st *MemoryStorage) Remove(ctx context.Context, key string) error
- func (st *MemoryStorage) Stat(ctx context.Context, key string) (bool, error)
- func (st *MemoryStorage) WalkKeys(ctx context.Context, opts WalkKeysOptions) error
- func (st *MemoryStorage) WriteBytes(ctx context.Context, key string, b []byte) (int, error)
- func (st *MemoryStorage) WriteStream(ctx context.Context, key string, r io.Reader) (int64, error)
- type S3Config
- type S3Storage
- func (st *S3Storage) Clean(ctx context.Context) error
- func (st *S3Storage) Client() *minio.Core
- func (st *S3Storage) Close() error
- func (st *S3Storage) ReadBytes(ctx context.Context, key string) ([]byte, error)
- func (st *S3Storage) ReadStream(ctx context.Context, key string) (io.ReadCloser, error)
- func (st *S3Storage) Remove(ctx context.Context, key string) error
- func (st *S3Storage) Stat(ctx context.Context, key string) (bool, error)
- func (st *S3Storage) WalkKeys(ctx context.Context, opts WalkKeysOptions) error
- func (st *S3Storage) WriteBytes(ctx context.Context, key string, value []byte) (int, error)
- func (st *S3Storage) WriteStream(ctx context.Context, key string, r io.Reader) (int64, error)
- type Storage
- type WalkKeysOptions
Constants ¶
const LockFile = "store.lock"
LockFile is our standard lockfile name.
Variables ¶
var ( // ErrClosed is returned on operations on a closed storage ErrClosed = new_error("closed") // ErrNotFound is the error returned when a key cannot be found in storage ErrNotFound = new_error("key not found") // ErrAlreadyExist is the error returned when a key already exists in storage ErrAlreadyExists = new_error("key already exists") // ErrInvalidkey is the error returned when an invalid key is passed to storage ErrInvalidKey = new_error("invalid key") // ErrAlreadyLocked is returned on fail opening a storage lockfile ErrAlreadyLocked = new_error("storage lock already open") )
var DefaultDiskConfig = &DiskConfig{ Overwrite: true, WriteBufSize: 4096, Transform: NopTransform(), Compression: NoCompression(), }
DefaultDiskConfig is the default DiskStorage configuration.
var DefaultS3Config = &S3Config{
CoreOpts: minio.Options{},
GetOpts: minio.GetObjectOptions{},
PutOpts: minio.PutObjectOptions{},
PutChunkOpts: minio.PutObjectPartOptions{},
PutChunkSize: 4 * 1024 * 1024,
StatOpts: minio.StatObjectOptions{},
RemoveOpts: minio.RemoveObjectOptions{},
ListSize: 200,
}
DefaultS3Config is the default S3Storage configuration.
Functions ¶
This section is empty.
Types ¶
type Compressor ¶
type Compressor interface { // Reader returns a new decompressing io.ReadCloser based on supplied (compressed) io.Reader Reader(io.ReadCloser) (io.ReadCloser, error) // Writer returns a new compressing io.WriteCloser based on supplied (uncompressed) io.Writer Writer(io.WriteCloser) (io.WriteCloser, error) }
Compressor defines a means of compressing/decompressing values going into a key-value store
func GZipCompressor ¶
func GZipCompressor() Compressor
GZipCompressor returns a new Compressor that implements GZip at default compression level
func GZipCompressorLevel ¶
func GZipCompressorLevel(level int) Compressor
GZipCompressorLevel returns a new Compressor that implements GZip at supplied compression level
func NoCompression ¶
func NoCompression() Compressor
NoCompression is a Compressor that simply does nothing.
func SnappyCompressor ¶
func SnappyCompressor() Compressor
SnappyCompressor returns a new Compressor that implements Snappy.
func ZLibCompressor ¶
func ZLibCompressor() Compressor
ZLibCompressor returns a new Compressor that implements ZLib at default compression level
func ZLibCompressorLevel ¶
func ZLibCompressorLevel(level int) Compressor
ZLibCompressorLevel returns a new Compressor that implements ZLib at supplied compression level
func ZLibCompressorLevelDict ¶
func ZLibCompressorLevelDict(level int, dict []byte) Compressor
ZLibCompressorLevelDict returns a new Compressor that implements ZLib at supplied compression level with supplied dict
type DiskConfig ¶
type DiskConfig struct { // Transform is the supplied key <--> path KeyTransform. Transform KeyTransform // WriteBufSize is the buffer size to use when writing file streams. WriteBufSize int // Overwrite allows overwriting values of stored keys in the storage. Overwrite bool // LockFile allows specifying the filesystem path to use for the lockfile, // providing only a filename it will store the lockfile within provided store // path and nest the store under `path/store` to prevent access to lockfile. LockFile string // Compression is the Compressor to use when reading / writing files, // default is no compression. Compression Compressor }
DiskConfig defines options to be used when opening a DiskStorage.
type DiskStorage ¶
type DiskStorage struct {
// contains filtered or unexported fields
}
DiskStorage is a Storage implementation that stores directly to a filesystem.
func OpenDisk ¶
func OpenDisk(path string, cfg *DiskConfig) (*DiskStorage, error)
OpenDisk opens a DiskStorage instance for given folder path and configuration.
func (*DiskStorage) Clean ¶
func (st *DiskStorage) Clean(ctx context.Context) error
Clean implements Storage.Clean().
func (*DiskStorage) Filepath ¶ added in v2.2.2
func (st *DiskStorage) Filepath(key string) (string, error)
Filepath checks and returns a formatted Filepath for given key.
func (*DiskStorage) ReadStream ¶
func (st *DiskStorage) ReadStream(ctx context.Context, key string) (io.ReadCloser, error)
ReadStream implements Storage.ReadStream().
func (*DiskStorage) Remove ¶
func (st *DiskStorage) Remove(ctx context.Context, key string) error
Remove implements Storage.Remove().
func (*DiskStorage) WalkKeys ¶
func (st *DiskStorage) WalkKeys(ctx context.Context, opts WalkKeysOptions) error
WalkKeys implements Storage.WalkKeys().
func (*DiskStorage) WriteBytes ¶
WriteBytes implements Storage.WriteBytes().
func (*DiskStorage) WriteStream ¶
WriteStream implements Storage.WriteStream().
type Entry ¶
type Entry struct { // Key is this entry's unique storage key. Key string // Size is the size of this entry in storage. // Note that size < 0 indicates unknown. Size int64 }
Entry represents a key in a Storage{} implementation, with any associated metadata that may have been set.
type KeyTransform ¶
type KeyTransform interface { // KeyToPath converts a supplied key to storage path KeyToPath(string) string // PathToKey converts a supplied storage path to key PathToKey(string) string }
KeyTransform defines a method of converting store keys to storage paths (and vice-versa)
func NopTransform ¶
func NopTransform() KeyTransform
NopTransform returns a nop key transform (i.e. key = path)
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
Lock represents a filesystem lock to ensure only one storage instance open per path.
type MemoryStorage ¶
type MemoryStorage struct {
// contains filtered or unexported fields
}
MemoryStorage is a storage implementation that simply stores key-value pairs in a Go map in-memory. The map is protected by a mutex.
func OpenMemory ¶
func OpenMemory(size int, overwrites bool) *MemoryStorage
OpenMemory opens a new MemoryStorage instance with internal map starting size.
func (*MemoryStorage) Clean ¶
func (st *MemoryStorage) Clean(ctx context.Context) error
Clean implements Storage.Clean().
func (*MemoryStorage) Close ¶
func (st *MemoryStorage) Close() error
Close implements Storage.Close().
func (*MemoryStorage) ReadStream ¶
func (st *MemoryStorage) ReadStream(ctx context.Context, key string) (io.ReadCloser, error)
ReadStream implements Storage.ReadStream().
func (*MemoryStorage) Remove ¶
func (st *MemoryStorage) Remove(ctx context.Context, key string) error
Remove implements Storage.Remove().
func (*MemoryStorage) WalkKeys ¶
func (st *MemoryStorage) WalkKeys(ctx context.Context, opts WalkKeysOptions) error
WalkKeys implements Storage.WalkKeys().
func (*MemoryStorage) WriteBytes ¶
WriteBytes implements Storage.WriteBytes().
func (*MemoryStorage) WriteStream ¶
WriteStream implements Storage.WriteStream().
type S3Config ¶
type S3Config struct { // CoreOpts are S3 client options passed during initialization. CoreOpts minio.Options // GetOpts are S3 client options passed during .Read___() calls. GetOpts minio.GetObjectOptions // PutOpts are S3 client options passed during .Write___() calls. PutOpts minio.PutObjectOptions // PutChunkSize is the chunk size (in bytes) to use when sending // a byte stream reader of unknown size as a multi-part object. PutChunkSize int64 // PutChunkOpts are S3 client options passed during chunked .Write___() calls. PutChunkOpts minio.PutObjectPartOptions // StatOpts are S3 client options passed during .Stat() calls. StatOpts minio.StatObjectOptions // RemoveOpts are S3 client options passed during .Remove() calls. RemoveOpts minio.RemoveObjectOptions // ListSize determines how many items to include in each // list request, made during calls to .WalkKeys(). ListSize int }
S3Config defines options to be used when opening an S3Storage, mostly options for underlying S3 client library.
type S3Storage ¶
type S3Storage struct {
// contains filtered or unexported fields
}
S3Storage is a storage implementation that stores key-value pairs in an S3 instance at given endpoint with bucket name.
func OpenS3 ¶
OpenS3 opens a new S3Storage instance with given S3 endpoint URL, bucket name and configuration.
func (*S3Storage) Client ¶ added in v2.0.2
func (st *S3Storage) Client() *minio.Core
Client returns access to the underlying S3 client.
func (*S3Storage) ReadStream ¶
ReadStream implements Storage.ReadStream().
func (*S3Storage) WalkKeys ¶
func (st *S3Storage) WalkKeys(ctx context.Context, opts WalkKeysOptions) error
WalkKeys implements Storage.WalkKeys().
func (*S3Storage) WriteBytes ¶
WriteBytes implements Storage.WriteBytes().
type Storage ¶
type Storage interface { // ReadBytes returns the byte value for key in storage ReadBytes(ctx context.Context, key string) ([]byte, error) // ReadStream returns an io.ReadCloser for the value bytes at key in the storage ReadStream(ctx context.Context, key string) (io.ReadCloser, error) // WriteBytes writes the supplied value bytes at key in the storage WriteBytes(ctx context.Context, key string, value []byte) (int, error) // WriteStream writes the bytes from supplied reader at key in the storage WriteStream(ctx context.Context, key string, r io.Reader) (int64, error) // Stat checks if the supplied key is in the storage Stat(ctx context.Context, key string) (bool, error) // Remove attempts to remove the supplied key-value pair from storage Remove(ctx context.Context, key string) error // Close will close the storage, releasing any file locks Close() error // Clean removes unused values and unclutters the storage (e.g. removing empty folders) Clean(ctx context.Context) error // WalkKeys walks the keys in the storage WalkKeys(ctx context.Context, opts WalkKeysOptions) error }
Storage defines a means of storing and accessing key value pairs