Documentation
¶
Index ¶
- Variables
- type Dict
- type InMem
- type IterFn
- type Op
- type OpType
- type State
- type Transactional
- func (t *Transactional) AbortTx() error
- func (t *Transactional) Apply(ops []Op) error
- func (t *Transactional) BeginTx() error
- func (t *Transactional) CommitTx() error
- func (t *Transactional) Dict(name string) Dict
- func (t *Transactional) HasEmptyTx() bool
- func (t *Transactional) Reset()
- func (t *Transactional) Restore(b []byte) error
- func (t *Transactional) Save() ([]byte, error)
- func (t *Transactional) Tx() Tx
- func (t *Transactional) TxOps() []Op
- func (t *Transactional) TxStatus() TxStatus
- type Tx
- type TxDict
- func (d *TxDict) AbortTx() error
- func (d *TxDict) BeginTx() error
- func (d *TxDict) CommitTx() error
- func (d *TxDict) Del(k string) error
- func (d *TxDict) ForEach(f IterFn)
- func (d *TxDict) Get(k string) (interface{}, error)
- func (d *TxDict) Name() string
- func (d *TxDict) Put(k string, v interface{}) error
- type TxStatus
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrOpenTx error = errors.New("tx: transaction is already open") ErrNoTx error = errors.New("tx: no open transaction") )
View Source
var (
ErrNoSuchKey error = errors.New("state: no such key")
)
Functions ¶
This section is empty.
Types ¶
type Dict ¶
type Dict interface { // Name returns the name the dictionary. Name() string // Get the value associated with k. Get(key string) (val interface{}, err error) // Associate value with the key. Put(key string, val interface{}) error // Del deletes key from dictionary. Del(key string) error // ForEach iterates over all entries in the dictionary, and invokes f for // each entry. ForEach(f IterFn) }
Dict is a simple key-value store.
type InMem ¶
type InMem struct {
InMemDicts map[string]*inMemDict
}
InMem is a simple dictionary that uses in memory maps.
type IterFn ¶
IterFn is the function used to iterate the entries of a dictionary. If it returns false the foreach loop will stop.
type State ¶
type State interface { // Returns a dictionary for this state. Creates one if it does not exist. Dict(name string) Dict // Dicts returns all the dictionaries created in the state. Dicts() []Dict // Save save the state into bytes. Save() ([]byte, error) // Restore restores the state from b. Restore(b []byte) error }
State is a collection of dictionaries.
type Transactional ¶
type Transactional struct { State // contains filtered or unexported fields }
Transactional wraps any state dictionary and makes it transactional.
func NewTransactional ¶
func NewTransactional(s State) *Transactional
NewTransactional wraps s and writtens a transactional state.
func (*Transactional) AbortTx ¶
func (t *Transactional) AbortTx() error
func (*Transactional) Apply ¶
func (t *Transactional) Apply(ops []Op) error
func (*Transactional) BeginTx ¶
func (t *Transactional) BeginTx() error
func (*Transactional) CommitTx ¶
func (t *Transactional) CommitTx() error
func (*Transactional) Dict ¶
func (t *Transactional) Dict(name string) Dict
func (*Transactional) HasEmptyTx ¶
func (t *Transactional) HasEmptyTx() bool
func (*Transactional) Reset ¶
func (t *Transactional) Reset()
func (*Transactional) Restore ¶
func (t *Transactional) Restore(b []byte) error
func (*Transactional) Save ¶
func (t *Transactional) Save() ([]byte, error)
func (*Transactional) Tx ¶
func (t *Transactional) Tx() Tx
func (*Transactional) TxOps ¶
func (t *Transactional) TxOps() []Op
func (*Transactional) TxStatus ¶
func (t *Transactional) TxStatus() TxStatus
type Tx ¶
Tx represents the side effects of an operation: messages emitted during the transaction as well as state operations.
Click to show internal directories.
Click to hide internal directories.