Documentation ¶
Index ¶
- type Action
- type ActionType
- type Client
- func (c *Client) Close() error
- func (c *Client) GetStoreLink(ctx context.Context, storeID string) ([]string, error)
- func (c *Client) Listen(ctx context.Context, storeID string, listenOptions ...ListenOption) (<-chan ListenEvent, error)
- func (c *Client) ModelCreate(ctx context.Context, storeID, modelName string, items ...interface{}) error
- func (c *Client) ModelDelete(ctx context.Context, storeID, modelName string, entityIDs ...string) error
- func (c *Client) ModelFind(ctx context.Context, storeID, modelName string, query *store.JSONQuery, ...) (interface{}, error)
- func (c *Client) ModelFindByID(ctx context.Context, storeID, modelName, entityID string, entity interface{}) error
- func (c *Client) ModelHas(ctx context.Context, storeID, modelName string, entityIDs ...string) (bool, error)
- func (c *Client) ModelSave(ctx context.Context, storeID, modelName string, items ...interface{}) error
- func (c *Client) NewStore(ctx context.Context) (string, error)
- func (c *Client) ReadTransaction(ctx context.Context, storeID, modelName string) (*ReadTransaction, error)
- func (c *Client) RegisterSchema(ctx context.Context, storeID, name, schema string) error
- func (c *Client) Start(ctx context.Context, storeID string) error
- func (c *Client) StartFromAddress(ctx context.Context, storeID string, addr ma.Multiaddr, ...) error
- func (c *Client) WriteTransaction(ctx context.Context, storeID, modelName string) (*WriteTransaction, error)
- type EndTransactionFunc
- type ListenActionType
- type ListenEvent
- type ListenOption
- type ReadTransaction
- func (t *ReadTransaction) Find(query *store.JSONQuery, dummySlice interface{}) (interface{}, error)
- func (t *ReadTransaction) FindByID(entityID string, entity interface{}) error
- func (t *ReadTransaction) Has(entityIDs ...string) (bool, error)
- func (t *ReadTransaction) Start() (EndTransactionFunc, error)
- type WriteTransaction
- func (t *WriteTransaction) Create(items ...interface{}) error
- func (t *WriteTransaction) Delete(entityIDs ...string) error
- func (t *WriteTransaction) Find(query *store.JSONQuery, dummySlice interface{}) (interface{}, error)
- func (t *WriteTransaction) FindByID(entityID string, entity interface{}) error
- func (t *WriteTransaction) Has(entityIDs ...string) (bool, error)
- func (t *WriteTransaction) Save(items ...interface{}) error
- func (t *WriteTransaction) Start() (EndTransactionFunc, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action struct { Model string Type ActionType EntityID string Entity []byte }
Action represents a data event delivered to a listener
type ActionType ¶
type ActionType int
ActionType describes the type of event action when subscribing to data updates
const ( // ActionCreate represents an event for creating a new entity ActionCreate ActionType = iota + 1 // ActionSave represents an event for saving changes to an existing entity ActionSave // ActionDelete represents an event for deleting existing entity ActionDelete )
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides the client api
func (*Client) GetStoreLink ¶
GetStoreLink retrives the components required to create a Thread/store invite.
func (*Client) Listen ¶
func (c *Client) Listen(ctx context.Context, storeID string, listenOptions ...ListenOption) (<-chan ListenEvent, error)
Listen provides an update whenever the specified store, model type, or model instance is updated
func (*Client) ModelCreate ¶
func (c *Client) ModelCreate(ctx context.Context, storeID, modelName string, items ...interface{}) error
ModelCreate creates new instances of model objects
func (*Client) ModelDelete ¶
func (c *Client) ModelDelete(ctx context.Context, storeID, modelName string, entityIDs ...string) error
ModelDelete deletes data
func (*Client) ModelFind ¶
func (c *Client) ModelFind(ctx context.Context, storeID, modelName string, query *store.JSONQuery, dummySlice interface{}) (interface{}, error)
ModelFind finds records by query
func (*Client) ModelFindByID ¶
func (c *Client) ModelFindByID(ctx context.Context, storeID, modelName, entityID string, entity interface{}) error
ModelFindByID finds a record by id
func (*Client) ModelHas ¶
func (c *Client) ModelHas(ctx context.Context, storeID, modelName string, entityIDs ...string) (bool, error)
ModelHas checks if the specified entities exist
func (*Client) ModelSave ¶
func (c *Client) ModelSave(ctx context.Context, storeID, modelName string, items ...interface{}) error
ModelSave saves existing instances
func (*Client) ReadTransaction ¶
func (c *Client) ReadTransaction(ctx context.Context, storeID, modelName string) (*ReadTransaction, error)
ReadTransaction returns a read transaction that can be started and used and ended
func (*Client) RegisterSchema ¶
RegisterSchema registers a new model shecma
func (*Client) StartFromAddress ¶
func (c *Client) StartFromAddress(ctx context.Context, storeID string, addr ma.Multiaddr, followKey, readKey *symmetric.Key) error
StartFromAddress starts the specified Store with the provided address and keys
func (*Client) WriteTransaction ¶
func (c *Client) WriteTransaction(ctx context.Context, storeID, modelName string) (*WriteTransaction, error)
WriteTransaction returns a read transaction that can be started and used and ended
type EndTransactionFunc ¶
type EndTransactionFunc = func() error
EndTransactionFunc must be called to end a transaction after it has been started
type ListenActionType ¶
type ListenActionType int
ListenActionType describes the type of event action when receiving data updates
const ( // ListenAll specifies that Create, Save, and Delete events should be listened for ListenAll ListenActionType = iota // ListenCreate specifies that Create events should be listened for ListenCreate // ListenSave specifies that Save events should be listened for ListenSave // ListenDelete specifies that Delete events should be listened for ListenDelete )
type ListenEvent ¶
type ListenEvent struct {
// contains filtered or unexported fields
}
ListenEvent is used to send data or error values for Listen
type ListenOption ¶
type ListenOption struct { Type ListenActionType Model string EntityID string }
ListenOption represents a filter to apply when listening for data updates
type ReadTransaction ¶
type ReadTransaction struct {
// contains filtered or unexported fields
}
ReadTransaction encapsulates a read transaction
func (*ReadTransaction) Find ¶
func (t *ReadTransaction) Find(query *store.JSONQuery, dummySlice interface{}) (interface{}, error)
Find finds entities by query
func (*ReadTransaction) FindByID ¶
func (t *ReadTransaction) FindByID(entityID string, entity interface{}) error
FindByID gets the entity with the specified ID
func (*ReadTransaction) Has ¶
func (t *ReadTransaction) Has(entityIDs ...string) (bool, error)
Has runs a has query in the active transaction
func (*ReadTransaction) Start ¶
func (t *ReadTransaction) Start() (EndTransactionFunc, error)
Start starts the read transaction
type WriteTransaction ¶
type WriteTransaction struct {
// contains filtered or unexported fields
}
WriteTransaction encapsulates a write transaction
func (*WriteTransaction) Create ¶
func (t *WriteTransaction) Create(items ...interface{}) error
Create creates new instances of model objects
func (*WriteTransaction) Delete ¶
func (t *WriteTransaction) Delete(entityIDs ...string) error
Delete deletes data
func (*WriteTransaction) Find ¶
func (t *WriteTransaction) Find(query *store.JSONQuery, dummySlice interface{}) (interface{}, error)
Find finds entities by query
func (*WriteTransaction) FindByID ¶
func (t *WriteTransaction) FindByID(entityID string, entity interface{}) error
FindByID gets the entity with the specified ID
func (*WriteTransaction) Has ¶
func (t *WriteTransaction) Has(entityIDs ...string) (bool, error)
Has runs a has query in the active transaction
func (*WriteTransaction) Save ¶
func (t *WriteTransaction) Save(items ...interface{}) error
Save saves existing instances
func (*WriteTransaction) Start ¶
func (t *WriteTransaction) Start() (EndTransactionFunc, error)
Start starts the write transaction