backend

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrIteratorDone may be thrown by list iterators to stop iteration.
	ErrIteratorDone = errors.New("accord: iterator done")
	// ErrInvalidHandle returned by the backend if the handle cannot be used or has expired.
	ErrInvalidHandle = errors.New("accord: invalid handle")
)

Functions

This section is empty.

Types

type Backend

type Backend interface {
	// Acquire acquires a new named resource handle within namespace until exp time.
	Acquire(ctx context.Context, owner, namespace, name string, exp time.Time, metadata map[string]string) (*HandleData, error)

	// Renew renews a handle with a specific exp time and returns the updated handle.
	Renew(ctx context.Context, owner string, handleID uuid.UUID, exp time.Time, metadata map[string]string) error

	// Done marks the resource as done.
	Done(ctx context.Context, owner string, handleID uuid.UUID, metadata map[string]string) error

	// Get retrieves handle data by ID.
	Get(ctx context.Context, handleID uuid.UUID) (*HandleData, error)

	// List iterates over done resources within a namespace
	List(ctx context.Context, req *rpc.ListRequest, iter Iterator) error

	// Ping pings the backend connection.
	Ping() error

	// Close closes the backend connection.
	Close() error
}

Backend represents a storage/persistent backend for handle information.

type HandleData

type HandleData struct {
	ID          uuid.UUID         // a unique identifier
	Namespace   string            // the namespace of the handle
	Name        string            // the name of the handle
	Owner       string            // last/current owner identifier
	ExpTime     time.Time         // expiration time
	DoneTime    time.Time         // done time
	NumAcquired int               // number of times acquired
	Metadata    map[string]string // custom metadata
}

HandleData is retrieved by the backend.

func (*HandleData) IsDone

func (h *HandleData) IsDone() bool

IsDone indicates when a resource is marked as done.

func (*HandleData) UpdateMetadata

func (h *HandleData) UpdateMetadata(meta map[string]string)

UpdateMetadata merged metadata.

type Iterator

type Iterator func(*HandleData) error

Iterator function. Return ErrIteratorDone to cancel gracefully.

Directories

Path Synopsis
Package direct implements a backend wrapper which allows to connect clients to a backend directly bypassing grpc servers.
Package direct implements a backend wrapper which allows to connect clients to a backend directly bypassing grpc servers.
Package mock implements an in-memory mock backend for testing.
Package mock implements an in-memory mock backend for testing.
Package postgres implements a postgres-based backend for storing state.
Package postgres implements a postgres-based backend for storing state.

Jump to

Keyboard shortcuts

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