Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultStoreOptions = StoreOptions{ // contains filtered or unexported fields }
DefaultStoreOptions represents the recommended default StoreOptions for a store.
ErrInvalidKey the storage key is invalid.
Functions ¶
Types ¶
type EmptyStoreOption ¶
type EmptyStoreOption struct{}
EmptyStoreOption does not alter the store configuration. It can be embedded in another structure to build custom options.
type Storage ¶
type Storage interface { // Open opens the store. Open() error // Put a value in the store. Put(namespace string, key []byte, value []byte) error // Get a value from the store. Get(namespace string, key []byte) (value []byte, err error) // Has checks for a key in the store. Has(namespace string, key []byte) (bool, error) // Save the value in v and stores the result at key. Save(namespace string, key []byte, v interface{}) error // Load the value at key and stores the result in v. Load(namespace string, key []byte, v interface{}) error // List returns a list of all keys in the namespace. List(namespace string) ([][]byte, error) // ListAll returns a mapped list of all keys in the store. ListAll() (map[string][][]byte, error) // Delete removes a key from the store. Delete(name string, key []byte) error // Close closes the store. Close() error // Export saves the store to path. Export(path string) error }
Storage provides a management interface for a datastore.
type StoreOption ¶
type StoreOption interface {
// contains filtered or unexported methods
}
A StoreOption sets options such disabling overwrite, and other parameters, etc.
func WithLogger ¶
func WithLogger(l log.Logger) StoreOption
WithLogger returns a StoreOption which sets the logger to use for the encrypted store.
func WithStdLogger ¶
func WithStdLogger(lvl log.Level) StoreOption
WithStdLogger is a convenience that returns a StoreOption for a standard err logger.
func WithZerologLogger ¶
func WithZerologLogger(lvl log.Level) StoreOption
WithZerologLogger is a convenience that returns a StoreOption for a default Zerolog logger.
type StoreOptions ¶
type StoreOptions struct {
// contains filtered or unexported fields
}
StoreOptions provides a default implementation for common storage Options stores should support.
func ApplyOptions ¶
func ApplyOptions(opts StoreOptions, opt ...StoreOption) StoreOptions
ApplyOptions accepts an StoreOptions struct and applies the StoreOption(s) to it.
func (StoreOptions) Logger ¶
func (o StoreOptions) Logger() log.Logger
Logger returns the configured logger for the store.