Documentation ¶
Overview ¶
Package storage contains the interface for storing and retrieving data about the state of the mesh.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrKeyNotFound = errors.New("key not found")
ErrKeyNotFound is the error returned when a key is not found.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct { // InMemory specifies whether to use an in-memory storage. InMemory bool // DiskPath is the path to the disk storage. DiskPath string // Silent specifies whether to suppress log output. Silent bool }
Options are the options for creating a new Storage.
type PrefixIterator ¶
PrefixIterator is the function signature for iterating over all keys with a given prefix.
type Storage ¶
type Storage interface { // Get returns the value of a key. Get(ctx context.Context, key string) (string, error) // Put sets the value of a key. TTL is optional and can be set to 0. Put(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. 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) (func(), error) // Close closes the storage. Close() error }
Storage is the interface for storing and retrieving data about the state of the mesh.
func NewTestStorage ¶
NewTestStorage is a helper for creating an in-memory storage suitable for testing.
type SubscribeFunc ¶
type SubscribeFunc func(key, value string)
SubscribeFunc is the function signature for subscribing to changes to a key.
Click to show internal directories.
Click to hide internal directories.