storage

package
v0.0.0-...-0b17bab Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InMemoryStorage

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

InMemoryStorage is a memory-backed (non-persistent) implementation of Storage, useful for tests.

func NewInMemoryStorage

func NewInMemoryStorage() *InMemoryStorage

NewInMemoryStorage constructs an InMemoryStorage

func (*InMemoryStorage) Create

func (s *InMemoryStorage) Create(ctx context.Context, fqn string, create proto.Message) error

Create stores the object, erroring if it already exists

func (*InMemoryStorage) Delete

func (s *InMemoryStorage) Delete(ctx context.Context, fqn string, dest proto.Message) error

Delete deletes the object, returning a not found error if it does not exist.

func (*InMemoryStorage) Get

func (s *InMemoryStorage) Get(ctx context.Context, fqn string, dest proto.Message) error

Get returns an existing object

func (*InMemoryStorage) List

func (s *InMemoryStorage) List(ctx context.Context, kind protoreflect.Descriptor, options ListOptions, callback func(obj proto.Message) error) error

List returns all matching objects

func (*InMemoryStorage) Update

func (s *InMemoryStorage) Update(ctx context.Context, fqn string, update proto.Message) error

Update stores a new version of an object, erroring if it does not already exist

type ListOptions

type ListOptions struct {
	// Prefix ensures that only objects whose key matches the prefix are returned
	Prefix string
}

ListOptions restricts the objects returned by a List

type Storage

type Storage interface {
	// Create stores the object, erroring if it already exists
	Create(ctx context.Context, fqn string, create proto.Message) error

	// Update stores a new version of an object, erroring if it does not already exist
	Update(ctx context.Context, fqn string, update proto.Message) error

	// Get returns an existing object.
	// The error is "ready to return"; we return codes.NotFound if not found.
	Get(ctx context.Context, fqn string, dest proto.Message) error

	// List returns all matching objects
	List(ctx context.Context, kind protoreflect.Descriptor, options ListOptions, callback func(obj proto.Message) error) error

	// Delete deletes the object, returning a not found error if it does not exist.
	// The error is "ready to return", e.g. we return codes.NotFound if not found.
	Delete(ctx context.Context, fqn string, dest proto.Message) error
}

Jump to

Keyboard shortcuts

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