storage

package
v0.0.13 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRootWithParentDirectory is returned when a root directory has a parent directory.
	ErrRootWithParentDirectory = errors.New("root directory cannot have parent directory")

	// ErrNoRowsAffected is returned when no rows are affected by an operation.
	ErrNoRowsAffected = errors.New("no rows affected")

	// ErrDirectoryWithoutParent is returned when a directory does not have a parent directory.
	ErrDirectoryWithoutParent = errors.New("directory must have a parent directory")

	// ErrDirectoryNotFound is returned when a directory is not found.
	ErrDirectoryNotFound = errors.New("directory not found")

	// ErrReadOnly is returned when a write operation is attempted on a read-only driver.
	ErrReadOnly = errors.New("attempted write operation on read-only driver")

	// ErrNoRootAccess is returned when a root directory is attempted to be accessed
	// without root access.
	ErrNoRootAccess = errors.New("attempted to access root directory without root access")
)

Functions

This section is empty.

Types

type DirectoryAdmin

type DirectoryAdmin interface {
	RootReader
	RootWriter
}

DirectoryAdmin is the interface that allows doing all operations on the directory tree.

type Option added in v0.0.13

type Option func(opts *Options)

Option defines a storage Options handler.

var WithDeletedDirectories Option = func(opts *Options) {
	opts.WithDeletedDirectories = true
}

WithDeletedDirectories includes deleted directories in queries.

type Options added in v0.0.13

type Options struct {
	// WithDeletedDirectories includes deleted directories in queries.
	WithDeletedDirectories bool
}

Options contains all possible storage options.

func BuildOptions added in v0.0.13

func BuildOptions(opts []Option) *Options

BuildOptions applies all options to a new Options instance.

type Reader

type Reader interface {
	GetDirectory(ctx context.Context, id v1.DirectoryID, options ...Option) (*v1.Directory, error)
	GetParents(ctx context.Context, id v1.DirectoryID, options ...Option) ([]v1.DirectoryID, error)
	GetParentsUntilAncestor(
		ctx context.Context,
		child, ancestor v1.DirectoryID,
		options ...Option,
	) ([]v1.DirectoryID, error)
	GetChildren(ctx context.Context, id v1.DirectoryID, options ...Option) ([]v1.DirectoryID, error)
}

Reader is the interface that allows doing basic read operations on the directory tree.

type RootReader

type RootReader interface {
	Reader
	ListRoots(ctx context.Context, options ...Option) ([]v1.DirectoryID, error)
}

RootReader is the interface that allows doing all read operations on the directory tree.

type RootWriter

type RootWriter interface {
	Writer
	CreateRoot(ctx context.Context, d *v1.Directory) (*v1.Directory, error)
}

RootWriter is the interface that allows doing all write operations.

type Writer

type Writer interface {
	CreateDirectory(ctx context.Context, d *v1.Directory) (*v1.Directory, error)
	UpdateDirectory(ctx context.Context, d *v1.Directory) error
	DeleteDirectory(ctx context.Context, id v1.DirectoryID) ([]*v1.Directory, error)
}

Writer is the interface that allows doing basic write operations.

Directories

Path Synopsis
crdb
migrations
Package db provides an embedded filesystem containing all the database migrations
Package db provides an embedded filesystem containing all the database migrations
Package memory implements a memory storage backend for the fertilesoil storage interface.
Package memory implements a memory storage backend for the fertilesoil storage interface.

Jump to

Keyboard shortcuts

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