storage

package
v0.0.0-...-c9bb2cb Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsConflictErr

func IsConflictErr(err error) bool

IsConflictErr checks to see if the passed error occurred because of a version conflict. Errors comply to this if they have a `ConflictErr()` method

func IsNotFoundErr

func IsNotFoundErr(err error) bool

IsNotFoundErr checks to see if the passed error is because the item was not found, as opposed to an actual error state. Errors comply to this if they have an `NotFoundErr()` method.

func NewID

func NewID() string

NewID returns a random string which can be used as an ID for objects.

func Test

func Test(ctx context.Context, t *testing.T, s Storage)

Types

type Storage

type Storage interface {
	// Get returns the given item. If the item doesn't exist, an IsNotFoundErr
	// will be returned. The returned version should be submitted with any
	// updates to the returned object
	Get(ctx context.Context, keyspace, key string, into proto.Message) (version int64, err error)
	// Put stores the provided item. If this is an update to an existing object
	// it's version should be included; for new objects the version should be 0. If
	// the update fails because of a version conflict, an IsConflictErr will be
	// returned. Any existing expiration set on the object should be preserved.
	Put(ctx context.Context, keyspace, key string, version int64, obj proto.Message) (newVersion int64, err error)
	// PutWithExpiry is a Put, with a time that the item should no longer
	// be accessible. This doesn't guarantee that the data will be deleted at
	// the time, but Get should not return it.
	PutWithExpiry(ctx context.Context, keyspace, key string, version int64, obj proto.Message, expires time.Time) (newVersion int64, err error)
	// List retrieves all keys in the given keyspace.
	List(ctx context.Context, keyspace string) (keys []string, err error)
	// Delete removes the item. If the item doesn't exist, an IsNotFoundErr will
	// be returned.
	Delete(ctx context.Context, keyspace, key string) error
}

Storage is an interface used by the service to maintain state.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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