Documentation ¶
Index ¶
- Variables
- type Backend
- type KeyValueStore
- type MockBackend
- type MockKeyValueStore
- func (_m *MockKeyValueStore) Delete(ctx context.Context, key string) error
- func (_m *MockKeyValueStore) Get(key string) ([]byte, error)
- func (_m *MockKeyValueStore) List(re string) (map[string][]byte, error)
- func (_m *MockKeyValueStore) Name() string
- func (_m *MockKeyValueStore) Put(ctx context.Context, key string, value []byte) error
- func (_m *MockKeyValueStore) Save(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrKeyNotFound = errors.New("key not found")
)
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface { // Save saves data to the specified path Save(ctx context.Context, r io.Reader, path string) error // Load loads data from the specified path Load(ctx context.Context, path string) (io.ReadCloser, error) }
func NewDatastoreBackend ¶
type KeyValueStore ¶
type KeyValueStore interface { // Set adds a new key or modifies an existing key in the key-value store Put(ctx context.Context, key string, value []byte) error // Get gets an existing key in the key-value store. Returns ErrKeyNotFound // if key does not exist the key-value store. Get(key string) ([]byte, error) // List lists the key-value pairs whose keys match the regular expression // passed in. List(re string) (map[string][]byte, error) // Delete deletes existing keys from the key-value store. Returns ErrKeyNotFound // if key does not exist the key-value store. Delete(ctx context.Context, key string) error // Save saves the key-value store data to the backend. Save(ctx context.Context) error // Name returns the unique identifier/name for the key-value store. This is // used to determine the path that is passed to the backend operations. Name() string }
func NewKeyValueStore ¶
Create a new KeyValueStore instance using the given Backend with the given file. If the file exists on the Backend, it is restored.
type MockBackend ¶
type MockBackend struct {
// contains filtered or unexported fields
}
func (*MockBackend) Load ¶
func (m *MockBackend) Load(ctx context.Context, pth string) (io.ReadCloser, error)
type MockKeyValueStore ¶
MockKeyValueStore is an autogenerated mock type for the KeyValueStore type
func (*MockKeyValueStore) Delete ¶
func (_m *MockKeyValueStore) Delete(ctx context.Context, key string) error
Delete provides a mock function with given fields: ctx, key
func (*MockKeyValueStore) Get ¶
func (_m *MockKeyValueStore) Get(key string) ([]byte, error)
Get provides a mock function with given fields: key
func (*MockKeyValueStore) List ¶
func (_m *MockKeyValueStore) List(re string) (map[string][]byte, error)
List provides a mock function with given fields: re
func (*MockKeyValueStore) Name ¶
func (_m *MockKeyValueStore) Name() string
Name provides a mock function with given fields:
Click to show internal directories.
Click to hide internal directories.