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 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 DualStorage
- type MeshStorage
- 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.
Functions ¶
func IsKeyNotFoundError ¶ added in v0.3.0
IsKeyNotFoundError returns true if the given error is a ErrKeyNotFound error.
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 DualStorage ¶ added in v0.3.0
type DualStorage interface { MeshStorage RaftStorage }
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 { // 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 PrefixIterator ¶
PrefixIterator is the function signature for iterating over all keys with a given prefix.
type RaftStorage ¶ added in v0.3.0
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 memory implements an in-memory storage backend suitable for testing.
|
Package memory implements an in-memory storage backend suitable for testing. |
Package nutsdb implements the storage backends using NutsDB.
|
Package nutsdb implements the storage backends using NutsDB. |