Documentation
¶
Index ¶
- type Action
- type ActionType
- type Client
- func (c *Client) Close() error
- func (c *Client) Create(ctx context.Context, dbID, collectionName string, items ...interface{}) error
- func (c *Client) Delete(ctx context.Context, dbID, collectionName string, instanceIDs ...string) error
- func (c *Client) Find(ctx context.Context, dbID, collectionName string, query *db.JSONQuery, ...) (interface{}, error)
- func (c *Client) FindByID(ctx context.Context, dbID, collectionName, instanceID string, ...) error
- func (c *Client) GetDBLink(ctx context.Context, dbID string) ([]string, error)
- func (c *Client) Has(ctx context.Context, dbID, collectionName string, instanceIDs ...string) (bool, error)
- func (c *Client) Listen(ctx context.Context, dbID string, listenOptions ...ListenOption) (<-chan ListenEvent, error)
- func (c *Client) NewCollection(ctx context.Context, dbID, name, schema string, indexes ...*db.IndexConfig) error
- func (c *Client) NewDB(ctx context.Context) (string, error)
- func (c *Client) ReadTransaction(ctx context.Context, dbID, collectionName string) (*ReadTransaction, error)
- func (c *Client) Save(ctx context.Context, dbID, collectionName string, items ...interface{}) error
- func (c *Client) Start(ctx context.Context, dbID string) error
- func (c *Client) StartFromAddress(ctx context.Context, dbID string, addr ma.Multiaddr, ...) error
- func (c *Client) WriteTransaction(ctx context.Context, dbID, collectionName string) (*WriteTransaction, error)
- type EndTransactionFunc
- type ListenActionType
- type ListenEvent
- type ListenOption
- type ReadTransaction
- func (t *ReadTransaction) Find(query *db.JSONQuery, dummySlice interface{}) (interface{}, error)
- func (t *ReadTransaction) FindByID(instanceID string, instance interface{}) error
- func (t *ReadTransaction) Has(instanceIDs ...string) (bool, error)
- func (t *ReadTransaction) Start() (EndTransactionFunc, error)
- type WriteTransaction
- func (t *WriteTransaction) Create(items ...interface{}) error
- func (t *WriteTransaction) Delete(instanceIDs ...string) error
- func (t *WriteTransaction) Find(query *db.JSONQuery, dummySlice interface{}) (interface{}, error)
- func (t *WriteTransaction) FindByID(instanceID string, instance interface{}) error
- func (t *WriteTransaction) Has(instanceIDs ...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 {
Collection string
Type ActionType
InstanceID string
Instance []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 instance ActionCreate ActionType = iota + 1 // ActionSave represents an event for saving changes to an existing instance ActionSave // ActionDelete represents an event for deleting existing instance ActionDelete )
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides the client api
func NewClient ¶
func NewClient(target string, opts ...grpc.DialOption) (*Client, error)
NewClient starts the client
func (*Client) Create ¶ added in v0.1.12
func (c *Client) Create(ctx context.Context, dbID, collectionName string, items ...interface{}) error
Create creates new instances of objects
func (*Client) Delete ¶ added in v0.1.12
func (c *Client) Delete(ctx context.Context, dbID, collectionName string, instanceIDs ...string) error
Delete deletes data
func (*Client) Find ¶ added in v0.1.12
func (c *Client) Find(ctx context.Context, dbID, collectionName string, query *db.JSONQuery, dummySlice interface{}) (interface{}, error)
Find finds instances by query
func (*Client) FindByID ¶ added in v0.1.12
func (c *Client) FindByID(ctx context.Context, dbID, collectionName, instanceID string, instance interface{}) error
FindByID finds an instance by id
func (*Client) Has ¶ added in v0.1.12
func (c *Client) Has(ctx context.Context, dbID, collectionName string, instanceIDs ...string) (bool, error)
Has checks if the specified instances exist
func (*Client) Listen ¶
func (c *Client) Listen(ctx context.Context, dbID string, listenOptions ...ListenOption) (<-chan ListenEvent, error)
Listen provides an update whenever the specified db, collection, or instance is updated
func (*Client) NewCollection ¶ added in v0.1.12
func (c *Client) NewCollection(ctx context.Context, dbID, name, schema string, indexes ...*db.IndexConfig) error
NewCollection creates a new collection
func (*Client) ReadTransaction ¶
func (c *Client) ReadTransaction(ctx context.Context, dbID, collectionName string) (*ReadTransaction, error)
ReadTransaction returns a read transaction that can be started and used and ended
func (*Client) StartFromAddress ¶
func (c *Client) StartFromAddress(ctx context.Context, dbID string, addr ma.Multiaddr, followKey, readKey *symmetric.Key) error
StartFromAddress starts the specified DB with the provided address and keys
func (*Client) WriteTransaction ¶
func (c *Client) WriteTransaction(ctx context.Context, dbID, collectionName 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 ¶
ListenEvent is used to send data or error values for Listen
type ListenOption ¶
type ListenOption struct {
Type ListenActionType
Collection string
InstanceID 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 *db.JSONQuery, dummySlice interface{}) (interface{}, error)
Find finds instances by query
func (*ReadTransaction) FindByID ¶
func (t *ReadTransaction) FindByID(instanceID string, instance interface{}) error
FindByID gets the instance with the specified ID
func (*ReadTransaction) Has ¶
func (t *ReadTransaction) Has(instanceIDs ...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 objects
func (*WriteTransaction) Delete ¶
func (t *WriteTransaction) Delete(instanceIDs ...string) error
Delete deletes data
func (*WriteTransaction) Find ¶
func (t *WriteTransaction) Find(query *db.JSONQuery, dummySlice interface{}) (interface{}, error)
Find finds instances by query
func (*WriteTransaction) FindByID ¶
func (t *WriteTransaction) FindByID(instanceID string, instance interface{}) error
FindByID gets the instance with the specified ID
func (*WriteTransaction) Has ¶
func (t *WriteTransaction) Has(instanceIDs ...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