memory

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: 7 Imported by: 0

Documentation

Overview

Package memory implements a memory storage backend for the fertilesoil storage interface. This is not meant to be the most useful nor the most performant storage backend, but rather a reference implementation which is useful for testing and development.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

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

func NewDirectoryDriver

func NewDirectoryDriver(opts ...Options) *Driver

func (*Driver) CreateDirectory

func (t *Driver) CreateDirectory(ctx context.Context, d *v1.Directory) (*v1.Directory, error)

CreateDirectory creates a directory. ID is generated by the database, it will be ignored if given.

func (*Driver) CreateRoot

func (t *Driver) CreateRoot(ctx context.Context, d *v1.Directory) (*v1.Directory, error)

CreateRoot creates a root directory. Root directories are directories that have no parent directory. ID is generated by the database, it will be ignored if given.

func (*Driver) DeleteDirectory

func (t *Driver) DeleteDirectory(ctx context.Context, id v1.DirectoryID) ([]*v1.Directory, error)

DeleteDirectory deletes a directory.

func (*Driver) GetChildren

func (t *Driver) GetChildren(
	ctx context.Context,
	id v1.DirectoryID,
	options ...storage.Option,
) ([]v1.DirectoryID, error)

GetChildren gets all child directories of a directory.

func (*Driver) GetDirectory

func (t *Driver) GetDirectory(
	ctx context.Context,
	id v1.DirectoryID,
	options ...storage.Option,
) (*v1.Directory, error)

GetDirectory gets a directory by ID.

func (*Driver) GetParents

func (t *Driver) GetParents(
	ctx context.Context,
	id v1.DirectoryID,
	options ...storage.Option,
) ([]v1.DirectoryID, error)

GetParents gets all parent directories of a directory.

func (*Driver) GetParentsUntilAncestor

func (t *Driver) GetParentsUntilAncestor(
	ctx context.Context,
	child,
	ancestor v1.DirectoryID,
	options ...storage.Option,
) ([]v1.DirectoryID, error)

GetParentsUntilAncestor gets all parent directories of a directory until the ancestor directory is reached.

func (*Driver) ListRoots

func (t *Driver) ListRoots(ctx context.Context, options ...storage.Option) ([]v1.DirectoryID, error)

ListRoots lists all root directories.

func (*Driver) UpdateDirectory added in v0.0.13

func (t *Driver) UpdateDirectory(ctx context.Context, d *v1.Directory) error

UpdateDirectory updates the directory provided.

type Options

type Options func(*Driver)

func WithDirectoryMap

func WithDirectoryMap(dirMap *sync.Map) Options

WithDirectoryMap allows to set a custom directory map. This is useful for testing, since it allows to inject a custom map and further modify it in the test.

Jump to

Keyboard shortcuts

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