Documentation ¶
Overview ¶
Package storage contains the interface for storing and retrieving data about the state of the mesh and providing storage backends for raft.
Index ¶
- Variables
- func IsKeyNotFoundError(err error) bool
- func IsReservedPrefix(key string) bool
- func NewKeyNotFoundError(key string) error
- func RunDualStorageConformance(t *testing.T, dualStorage DualStorage)
- func RunMeshStorageConformance(t *testing.T, meshStorage MeshStorage)
- func RunRaftStorageConformance(t *testing.T, raftStorage RaftStorage)
- type DropStorage
- type DualStorage
- type MeshStorage
- type Prefix
- type PrefixIterator
- type RaftStorage
- type SubscribeFunc
Constants ¶
This section is empty.
Variables ¶
var ErrKeyNotFound = errors.New("key not found")
ErrKeyNotFound is the error returned when a key is not found.
var ReservedPrefixes = []Prefix{ RegistryPrefix, RaftPrefix, }
ReservedPrefixes is a list of all reserved prefixes.
Functions ¶
func IsKeyNotFoundError ¶ added in v0.3.0
IsKeyNotFoundError returns true if the given error is a ErrKeyNotFound error.
func IsReservedPrefix ¶ added in v0.6.0
IsReservedPrefix returns true if the given key is reserved.
func NewKeyNotFoundError ¶ added in v0.3.0
NewKeyNotFoundError returns a new ErrKeyNotFound error.
func RunDualStorageConformance ¶ added in v0.3.0
func RunDualStorageConformance(t *testing.T, dualStorage DualStorage)
RunDualStorageConformance tests that the DualStorage interface is implemented correctly.
func RunMeshStorageConformance ¶ added in v0.3.0
func RunMeshStorageConformance(t *testing.T, meshStorage MeshStorage)
RunMeshStorageConformance tests that the MeshStorage interface is implemented correctly.
func RunRaftStorageConformance ¶ added in v0.3.0
func RunRaftStorageConformance(t *testing.T, raftStorage RaftStorage)
RunRaftStorageConformance tests that the RaftStorage interface is implemented correctly.
Types ¶
type DropStorage ¶ added in v0.6.0
type DropStorage interface { // DropAll drops all data from the storage. This is primarily used // for testing. DropAll(ctx context.Context) error }
DropStorage is a storage interface that can be dropped entirely. This is primarily used for testing.
type DualStorage ¶ added in v0.3.0
type DualStorage interface { MeshStorage RaftStorage DropStorage }
DualStorage represents a storage interface that can serve as both a mesh and Raft storage.
type MeshStorage ¶ added in v0.3.0
type MeshStorage interface { DropStorage // GetValue returns the value of a key. GetValue(ctx context.Context, key string) (string, error) // PutValue sets the value of a key. TTL is optional and can be set to 0. PutValue(ctx context.Context, key, value string, ttl time.Duration) error // Delete removes a key. Delete(ctx context.Context, key string) error // List returns all keys with a given prefix. List(ctx context.Context, prefix string) ([]string, error) // IterPrefix iterates over all keys with a given prefix. It is important // that the iterator not attempt any write operations as this will cause // a deadlock. The iteration will stop if the iterator returns an error. IterPrefix(ctx context.Context, prefix string, fn PrefixIterator) error // Snapshot returns a snapshot of the storage. Snapshot(ctx context.Context) (io.Reader, error) // Restore restores a snapshot of the storage. Restore(ctx context.Context, r io.Reader) error // Subscribe will call the given function whenever a key with the given prefix is changed. // The returned function can be called to unsubscribe. Subscribe(ctx context.Context, prefix string, fn SubscribeFunc) (context.CancelFunc, error) // Close closes the storage. Close() error }
MeshStorage is the interface for storing and retrieving data about the state of the mesh.
type Prefix ¶ added in v0.6.0
type Prefix string
Prefix is a prefix in the storage.
func (Prefix) Contains ¶ added in v0.6.0
Contains returns true if the given key is contained in the prefix.
type PrefixIterator ¶
PrefixIterator is the function signature for iterating over all keys with a given prefix.
type RaftStorage ¶ added in v0.3.0
type RaftStorage interface { raft.LogStore raft.StableStore DropStorage io.Closer }
RaftStorage is the interface for storing and retrieving data about the state of the mesh. This interface is used by mesh members that are part of the Raft cluster.
type SubscribeFunc ¶
type SubscribeFunc func(key, value string)
SubscribeFunc is the function signature for subscribing to changes to a key.
Directories ¶
Path | Synopsis |
---|---|
Package badgerdb implements the storage backends using BadgerDB.
|
Package badgerdb implements the storage backends using BadgerDB. |
Package memory implements an in-memory storage backend suitable for testing.
|
Package memory implements an in-memory storage backend suitable for testing. |