Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrDuplicateStore = errors.New("store already exists")
ErrDuplicateStore is used when an attempt is made to create a duplicate store.
var ErrGetAllNotSupported = errors.New("getting all key-value pairs is not supported")
ErrGetAllNotSupported is used when the get all function is not supported by the store implementation.
var ErrGetBulkKeysStringSliceNil = errors.New("keys string slice cannot be nil")
ErrGetBulkKeysStringSliceNil is returned when an attempt is made to call the GetBulk method with a nil slice of strings.
var ErrGetBulkNotImplemented = errors.New("get bulk not implemented")
ErrGetBulkNotImplemented is returned when GetBulk is not implemented by the store implementation.
var ErrIndexingNotSupported = errors.New("indexing is not supported")
ErrIndexingNotSupported is used when create index is not supported by the store implementation.
var ErrKeyRequired = errors.New("key is mandatory")
ErrKeyRequired is returned when an attempt is made to call a method with an empty key when it's not allowed.
var ErrKeysAndValuesDifferentLengths = errors.New("keys and values must be the same length")
ErrKeysAndValuesDifferentLengths is returned when an attempt is made to call the PutBulk method with differently sized keys and values arrays.
var ErrNilKeys = errors.New("keys slice cannot be nil")
ErrNilKeys is returned when PutBulk is called with a nil keys slice.
var ErrNilValues = errors.New("values slice cannot be nil")
ErrNilValues is returned when PutBulk is called with a nil values slice.
var ErrPutBulkNotImplemented = errors.New("put bulk not implemented")
ErrPutBulkNotImplemented is returned when PutBulk is not implemented by the store implementation.
var ErrQueryingNotSupported = errors.New("querying is not supported")
ErrQueryingNotSupported is used when querying is not supported by the store implementation.
var ErrStoreNotFound = errors.New("store not found")
ErrStoreNotFound is used when a given store was not found in a provider.
var ErrValueNotFound = errors.New("store does not have a value associated with this key")
ErrValueNotFound is used when an attempt is made to retrieve a value using a key that isn't in the store.
Functions ¶
This section is empty.
Types ¶
type CreateIndexRequest ¶ added in v0.1.3
type CreateIndexRequest struct {
// IndexStorageLocation is the place where the index (and any associated configuration data) is stored.
// The usage of this depends on the implementation.
IndexStorageLocation string
// IndexName is the user-defined name that should be assigned to this new index.
IndexName string
// WhatToIndex are the field(s) that you want to index.
// The syntax for this string depends on the implementation.
WhatToIndex string
}
CreateIndexRequest represents the information that a store needs to create a new user-specified index.
type Provider ¶
type Provider interface {
// CreateStore creates a new store with the given name.
CreateStore(name string) error
// OpenStore opens an existing store and returns it.
OpenStore(name string) (Store, error)
// CloseStore closes the store with the given name.
CloseStore(name string) error
// Close closes all stores created under this store provider.
Close() error
}
Provider represents a storage provider.
type ResultsIterator ¶ added in v0.1.3
type ResultsIterator interface {
// Next moves the pointer to the next value in the iterator. It returns false if the iterator is exhausted.
Next() (bool, error)
// Release releases associated resources. Release should always result in success
// and can be called multiple times without causing an error.
Release() error
// Key returns the key of the current key-value pair.
Key() (string, error)
// Value returns the value of the current key-value pair.
Value() ([]byte, error)
// Bookmark returns a value that's used for pagination.
// TODO (#51): Refactor querying to work more generically while supporting pagination.
Bookmark() string
}
ResultsIterator represents an iterator that can be used to iterate over all the stored key-value pairs.
type Store ¶
type Store interface {
// Put stores the key-value pair.
Put(k string, v []byte) error
// PutAll stores the key-value pairs in the order given in the array. Depending on the implementation
// this method may be faster than repeated Put calls. The keys and values slices must be the same length.
PutBulk(keys []string, values [][]byte) error
// Get fetches the value associated with the given key.
Get(k string) ([]byte, error)
// GetBulk fetches the values associated with the given keys. This method works in an all-or-nothing manner.
// It returns an error if any of the keys don't exist. If even one key is missing, then no values are returned.
// This method may be faster than calling Get for each key individually depending on the implementation.
GetBulk(k ...string) ([][]byte, error)
// GetAll fetches all the key-value pairs within this store.
GetAll() (map[string][]byte, error)
// CreateIndex creates an index in the store based on the provided CreateIndexRequest.
CreateIndex(createIndexRequest CreateIndexRequest) error
// Query queries the store for data based on the provided query string, the format of
// which will be dependent on what the underlying store requires.
// TODO (#51): Refactor querying to work more generically while supporting pagination.
Query(query string) (ResultsIterator, error)
// Delete deletes the key-value pair associated with k.
Delete(k string) error
}
Store represents a storage database.