Documentation ¶
Overview ¶
Package fakestore provides a fake in-mem storage. The implementation is based on the current real implementation using Datastore. See /lib/dsstore/ TODO: once we have a fake Datastore server, get rid of this.
Index ¶
- func Rev(rev int64) string
- type Data
- type KV
- type KVList
- type Key
- type State
- type Store
- func (s *Store) Delete(datatype, realm, user, id string, rev int64) error
- func (s *Store) DeleteTx(datatype, realm, user, id string, rev int64, tx storage.Tx) (ferr error)
- func (s *Store) Exists(datatype, realm, user, id string, rev int64) (_ bool, ferr error)
- func (s *Store) Info() map[string]string
- func (s *Store) LockTx(lockName string, minFrequency time.Duration, tx storage.Tx) storage.Tx
- func (s *Store) MultiDeleteTx(datatype, realm, user string, tx storage.Tx) (ferr error)
- func (s *Store) MultiReadTx(datatype, realm, user, id string, filters [][]storage.Filter, ...) (_ *storage.Results, ferr error)
- func (s *Store) Read(datatype, realm, user, id string, rev int64, content proto.Message) error
- func (s *Store) ReadHistory(datatype, realm, user, id string, content *[]proto.Message) error
- func (s *Store) ReadHistoryTx(datatype, realm, user, id string, content *[]proto.Message, tx storage.Tx) (ferr error)
- func (s *Store) ReadTx(datatype, realm, user, id string, rev int64, content proto.Message, ...) (ferr error)
- func (s *Store) Tx(update bool) (storage.Tx, error)
- func (s *Store) Wipe(ctx context.Context, realm string, batchNum, maxEntries int) (done int, ferr error)
- func (s *Store) Write(datatype, realm, user, id string, rev int64, content proto.Message, ...) error
- func (s *Store) WriteTx(datatype, realm, user, id string, rev int64, content proto.Message, ...) (ferr error)
- type Tx
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type KVList ¶
type KVList []KV
KVList is the type of list of (Key,Value) pairs. Used for sorting. Implements sort.Interface.
type State ¶
type State struct { // Version is a UUID that can be used to check if Data has changed. Version string // LastCommit is the timestamp for the last commit. // Useful for troubleshooting. LastCommit time.Time // Date enteries. Data Data // History entries. History Data }
State is the type containing the data in the store.
type Store ¶
type Store struct { // Information map. Information map[string]string // State is where the data resides. // Any block of code that wants to access the state reads it from the chan, // performs its operations, and then writes it back to the chan. // See https://bit.ly/37ANPk4 State chan State }
Store is a fake in-mem store of data.
func (*Store) MultiDeleteTx ¶
MultiDeleteTx deletes an item inside a transaction.
func (*Store) MultiReadTx ¶
func (s *Store) MultiReadTx( datatype, realm, user, id string, filters [][]storage.Filter, offset, pageSize int, typ proto.Message, tx storage.Tx, ) (_ *storage.Results, ferr error)
MultiReadTx reads a set of items matching the input parameters and filters. Returns total count and error.
content will contain the items which
their key matches the provided datatype, realm, user (if realm/user are not "") their value matches the provider filers
Items are sorted by their key's user and id in ascending order. The type of the item's value should be typ. Last revision of the items is used.
content's maps are keyed by user and id of the keys.
func (*Store) ReadHistory ¶
ReadHistory reads the history of a given key.
func (*Store) ReadHistoryTx ¶
func (s *Store) ReadHistoryTx(datatype, realm, user, id string, content *[]proto.Message, tx storage.Tx) (ferr error)
ReadHistoryTx reads the history of a given key inside a transaction.
func (*Store) ReadTx ¶
func (s *Store) ReadTx(datatype, realm, user, id string, rev int64, content proto.Message, tx storage.Tx) (ferr error)
ReadTx reads a data item of a given key inside a transaction. Calls Read if transaction is nil.
func (*Store) Wipe ¶
func (s *Store) Wipe(ctx context.Context, realm string, batchNum, maxEntries int) (done int, ferr error)
Wipe clears a realm.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx is a fake transaction.
func NewTx ¶
NewTx creates a new transaction. update determines if the transaction is a mutation or a read-only.
func (*Tx) Finish ¶
Finish attempts to commit a transaction. Returns error if the transaction is an update, is not rolled back, and cannot be committed because of conflict.
func (*Tx) MakeUpdate ¶ added in v0.8.8
MakeUpdate will upgrade a read-only transaction to an update transaction.