iodb

package module
v0.0.0-...-4c19b43 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

README

iodb

A simple filesystem-based bigfile k/v store.

Documentation

Index

Constants

View Source
const (
	// ErrNoReaders is returned when a reader is requested, but none are available
	ErrNoReaders = oerrs.String("no readers available")

	// ErrClosing is returned when an action is performed while a database is shutting down
	ErrClosing = oerrs.String("database is shutting down")

	// ErrInvalidBucketType is returned when an invalid bucket type is provided
	ErrInvalidBucketType = oerrs.String("invalid bucket type")

	// ErrKeyExists is returned when the key exists for a write action with overwrite set to false
	ErrKeyExists = oerrs.String("key already exists")

	// ErrSamePath is returned when the same path is used for a bucket
	ErrSamePath = oerrs.String("same path")
)
View Source
const ErrFileDoesNotExist = oerrs.String("file does not exist")

ErrFileDoesNotExist is returned when a file does not exist

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket interface {
	Append(key string, r io.Reader, middlewares ...mw.Middleware) (err error)
	AppendFunc(key string, fn func(w io.Writer) error, middlewares ...mw.Middleware) (err error)
	Bucket(names ...string) Bucket
	Buckets(rev bool) (out []string)
	CreateBucket(names ...string) (Bucket, error)
	Delete(key string) (err error)
	Rename(key string, nBkt Bucket, nKey string) (err error)
	DeleteBucket(name string) (err error)
	ForEach(fn func(key string, value io.Reader) error, middlewares ...mw.Middleware) error
	ForEachReverse(fn func(key string, value io.Reader) error, middlewares ...mw.Middleware) error
	Get(key string, middlewares ...mw.Middleware) (_ io.ReadCloser, err error)
	GetAndDelete(key string, fn func(r io.Reader) error, middlewares ...mw.Middleware) (err error)
	GetAndRename(key string, nBkt Bucket, nKey string, overwrite bool, fn ReaderFn, mws ...mw.Middleware) (err error)
	Group(mws ...mw.Middleware) Bucket
	Keys(reverse bool) (out []string)
	Name() string
	NextID() *big.Int
	Path() string
	Put(key string, r io.Reader, middlewares ...mw.Middleware) (err error)
	PutFunc(key string, fn func(w io.Writer) error, middlewares ...mw.Middleware) (err error)
	PutTimed(key string, r io.Reader, expireAfter time.Duration, middlewares ...mw.Middleware) (err error)
	PutTimedFunc(key string, fn func(w io.Writer) error, expireAfter time.Duration, middlewares ...mw.Middleware) (err error)
	Import(r io.Reader) (err error)
	Export(w io.Writer, exclude ...string) (err error)
	Stat(key string) (fi os.FileInfo, err error)
	SetExtraData(fileKey, key string, val string) error
	GetExtraData(fileKey, key string) (out string)
	ExtraData(fileKey string) (out map[string]string)
	AllExtraData() (out map[string]map[string]string)
}

Bucket is the interface for Bucket-like containers (buckets and groups)

type DB

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

func New

func New(path string, opts *Options) (*DB, error)

func (*DB) Bucket

func (db *DB) Bucket(names ...string) Bucket

func (*DB) Close

func (db *DB) Close() error

func (*DB) CreateBucket

func (db *DB) CreateBucket(names ...string) (Bucket, error)

func (*DB) Export

func (db *DB) Export(w io.Writer, exclude ...string) error

Export exports the database to a tar file.

func (*DB) ExportFile

func (db *DB) ExportFile(fn string, exclude ...string) error

ExportFile exports the entire database to a tar file. If the file has the gz suffix, it will be automatically compressed.

func (*DB) Group

func (db *DB) Group(mws ...mw.Middleware) Bucket

func (*DB) Import

func (db *DB) Import(r io.Reader) error

Import imports the database from a tar file.

type MiddlewareError

type MiddlewareError struct {
	Mw  mw.Middleware
	Err error
}

MiddlewareError represents an error that happened in a middleware

func (*MiddlewareError) Error

func (wr *MiddlewareError) Error() string

type Options

type Options struct {
	Middleware     []mw.Middleware
	PlainFileNames bool
}

Options allows a bit of customization for iodb.

type Reader

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

func (*Reader) Close

func (r *Reader) Close() error

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

func (*Reader) Stat

func (r *Reader) Stat() os.FileInfo

type ReaderFn

type ReaderFn func(io.Reader) error

ReaderFn is used for multi-use lock actions (Such as GetAndDelete and GetAndRename)

Directories

Path Synopsis
mw

Jump to

Keyboard shortcuts

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