client

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2020 License: MIT Imports: 13 Imported by: 36

Documentation

Index

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 NewClient

func NewClient(maddr ma.Multiaddr) (*Client, error)

NewClient starts the client

func (*Client) Close

func (c *Client) Close() error

Close closes the client's grpc connection and cancels any active requests

func (c *Client) GetStoreLink(ctx context.Context, storeID string) ([]string, error)

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) NewStore

func (c *Client) NewStore(ctx context.Context) (string, error)

NewStore cereates a new Store

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

func (c *Client) RegisterSchema(ctx context.Context, storeID, name, schema string) error

RegisterSchema registers a new model shecma

func (*Client) Start

func (c *Client) Start(ctx context.Context, storeID string) error

Start starts the specified Store

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

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

Start starts the write transaction

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL