Documentation ¶
Index ¶
Constants ¶
View Source
const ( ErrNotFound int = iota + 1 ErrAlreadyExists ErrInvalidObj ErrTimeout )
Variables ¶
This section is empty.
Functions ¶
func IsInvalidObj ¶
IsInvalidObj returns true if and only if err is invalid error
func IsNotFound ¶
IsNotFound returns true if and only if err is "key" not found error.
func IsRequestTimeout ¶
IsRequestTimeout returns true if and only if err indicates that the request has timed out.
Types ¶
type Key ¶
type Key struct {
types.NamespacedName
}
func KeyFromNSN ¶
func KeyFromNSN(nsn types.NamespacedName) Key
KeyFromNSN takes a types.NamespacedName and returns it wrapped in the Key struct.
type StorageError ¶
func NewAlreadyExistsError ¶
func NewAlreadyExistsError(key string) *StorageError
func NewInvalidObjError ¶
func NewInvalidObjError(key, msg string) *StorageError
func NewNotFoundError ¶
func NewNotFoundError(key string) *StorageError
func (*StorageError) Error ¶
func (r *StorageError) Error() string
type Storer ¶
type Storer[T1 any] interface { // Retrieve retrieves data for the given key from the storage Get(ctx context.Context, key Key) (T1, error) // Retrieve retrieves data for the given key from the storage List(ctx context.Context, visitorFunc func(context.Context, Key, T1)) error // Create data with the given key in the storage Create(ctx context.Context, key Key, data T1) error // Update data with the given key in the storage Update(ctx context.Context, key Key, data T1) error // Update data in a concurrent way through a function UpdateWithFn(ctx context.Context, updateFunc func(ctx context.Context, key Key, obj T1) T1) error // Update data in a concurrent way through a function UpdateWithKeyFn(ctx context.Context, key Key, updateFunc func(ctx context.Context, obj T1) T1) error // Delete deletes data and key from the storage Delete(ctx context.Context, key Key) error }
Storer defines the interface for a generic storage system.
Click to show internal directories.
Click to hide internal directories.