Documentation
¶
Overview ¶
MIT License Copyright (c) 2019 Tim Shannon Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Code has multiple changes compared to original, but corresponds proper mentioning.
Index ¶
- Variables
- func NewSimpleTx(ds datastore.Datastore) datastore.Txn
- func Where(field string) *criterion
- type Comparer
- type Dispatcher
- type MatchFunc
- type Model
- func (m *Model) Create(vs ...interface{}) error
- func (m *Model) Delete(ids ...core.EntityID) error
- func (m *Model) Find(result interface{}, q *Query) error
- func (m *Model) FindByID(id core.EntityID, v interface{}) error
- func (m *Model) Has(ids ...core.EntityID) (exists bool, err error)
- func (m *Model) ReadTxn(f func(txn *Txn) error) error
- func (m *Model) Reduce(event core.Event) error
- func (m *Model) Save(vs ...interface{}) error
- func (m *Model) WriteTxn(f func(txn *Txn) error) error
- type Query
- type Reducer
- type SimpleTx
- func (bt *SimpleTx) Commit() error
- func (bt *SimpleTx) Delete(key datastore.Key) error
- func (bt *SimpleTx) Discard()
- func (bt *SimpleTx) Get(k datastore.Key) ([]byte, error)
- func (bt *SimpleTx) GetSize(k datastore.Key) (int, error)
- func (bt *SimpleTx) Has(k datastore.Key) (bool, error)
- func (bt *SimpleTx) Put(key datastore.Key, val []byte) error
- func (bt *SimpleTx) Query(q query.Query) (query.Results, error)
- type Store
- type TxMapDatastore
- type Txn
- func (t *Txn) Commit() error
- func (t *Txn) Create(new ...interface{}) error
- func (t *Txn) Delete(ids ...core.EntityID) error
- func (t *Txn) Discard()
- func (t *Txn) Find(res interface{}, q *Query) error
- func (t *Txn) FindByID(id core.EntityID, v interface{}) error
- func (t *Txn) Has(ids ...core.EntityID) (bool, error)
- func (t *Txn) Save(updated ...interface{}) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("instance not found") ErrReadonlyTx = errors.New("read only transaction") ErrInvalidSchemaInstance = errors.New("instance doesn't correspond to schema") )
var ( ErrInvalidSortingField = errors.New("sorting field doesn't correspond to instance type") ErrCantCompareOnSort = errors.New("can't compare while sorting") )
var (
ErrInvalidModel = errors.New("the model is valid")
)
Functions ¶
Types ¶
type Comparer ¶
Comparer compares a type against the encoded value in the store. The result should be 0 if current==other, -1 if current < other, and +1 if current > other. If a field in a struct doesn't specify a comparer, then the default comparison is used (convert to string and compare) this interface is already handled for standard Go Types as well as more complex ones such as those in time and big an error is returned if the type cannot be compared The concrete type will always be passedin, not a pointer
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher is used to dispatch events to registered reducers.
This is different from generic pub-sub systems because reducers are not subscribed to particular events. Every event is dispatched to every registered reducer. When a given reducer is registered, it returns a `token`, which can be used to deregister the reducer later.
func NewDispatcher ¶
func NewDispatcher(store datastore.TxnDatastore) *Dispatcher
NewDispatcher creates a new EventDispatcher
func (*Dispatcher) Dispatch ¶
func (d *Dispatcher) Dispatch(event core.Event) error
Dispatch dispatches a payload to all registered reducers.
func (*Dispatcher) Query ¶
Query searches the internal event store and returns a query result. This is a syncronouse version of github.com/ipfs/go-datastore's Query method
func (*Dispatcher) Register ¶
func (d *Dispatcher) Register(reducer Reducer)
Register takes a reducer to be invoked with each dispatched event
func (*Dispatcher) Store ¶
func (d *Dispatcher) Store() datastore.TxnDatastore
Store returns the internal event store.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
func NewModel ¶
func NewModel(name string, defaultInstance interface{}, datastore ds.Datastore, dispatcher *Dispatcher, eventcreator core.EventCodec, s *Store) *Model
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
func (*Query) OrderByDesc ¶
type SimpleTx ¶
type SimpleTx struct {
// contains filtered or unexported fields
}
SimpleTx implements the transaction interface for datastores who do not have any sort of underlying transactional support
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func NewStore ¶
func NewStore(ds ds.Datastore, dispatcher *Dispatcher, ec core.EventCodec) *Store
NewStore creates a new Store, which will *own* ds and dispatcher for internal use. Saying it differently, ds and dispatcher shouldn't be used externally.
type TxMapDatastore ¶
type TxMapDatastore struct { *datastore.MapDatastore // contains filtered or unexported fields }
TxMapDatastore does stuff...
func NewTxMapDatastore ¶
func NewTxMapDatastore() *TxMapDatastore
func (*TxMapDatastore) NewTransaction ¶
func (d *TxMapDatastore) NewTransaction(readOnly bool) (datastore.Txn, error)
type Txn ¶
type Txn struct {
// contains filtered or unexported fields
}
Txn represents a read/write transaction in the Store. It allows for serializable isolation level within the store.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package broadcast implements multi-listener broadcast channels.
|
Package broadcast implements multi-listener broadcast channels. |
e2e
|
|