disk

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {

	// OpenRead are the arguments passed
	// to syscall.Open() when opening a
	// file for read operations.
	OpenRead OpenArgs

	// OpenWrite are the arguments passed
	// to syscall.Open() when opening a
	// file for write operations.
	OpenWrite OpenArgs

	// MkdirPerms are the permissions used
	// when creating necessary sub-dirs in
	// a storage key with slashes.
	MkdirPerms uint32

	// WriteBufSize is the buffer size
	// to use when writing file streams.
	WriteBufSize int
}

Config defines options to be used when opening a DiskStorage.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default DiskStorage configuration.

type DiskStorage

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

DiskStorage is a Storage implementation that stores directly to a filesystem.

func Open

func Open(path string, cfg *Config) (*DiskStorage, error)

Open 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

func (st *DiskStorage) Filepath(key string) (path string, err error)

Filepath checks and returns a formatted Filepath for given key.

func (*DiskStorage) ReadBytes

func (st *DiskStorage) ReadBytes(ctx context.Context, key string) ([]byte, error)

ReadBytes: implements Storage.ReadBytes().

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) Stat

func (st *DiskStorage) Stat(ctx context.Context, key string) (*storage.Entry, error)

Stat implements Storage.Stat().

func (*DiskStorage) WalkKeys

func (st *DiskStorage) WalkKeys(ctx context.Context, opts storage.WalkKeysOpts) error

WalkKeys implements Storage.WalkKeys().

func (*DiskStorage) WriteBytes

func (st *DiskStorage) WriteBytes(ctx context.Context, key string, value []byte) (int, error)

WriteBytes: implements Storage.WriteBytes().

func (*DiskStorage) WriteStream

func (st *DiskStorage) WriteStream(ctx context.Context, key string, stream io.Reader) (int64, error)

WriteStream: implements Storage.WriteStream().

type OpenArgs

type OpenArgs struct {
	Flags int
	Perms uint32
}

OpenArgs defines args passed in a syscall.Open() operation.

Jump to

Keyboard shortcuts

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