go-threads: github.com/textileio/go-threads/api/client Index | Files

package client

import "github.com/textileio/go-threads/api/client"

Index

Package Files

client.go read.go write.go

type Action Uses

type Action struct {
    Collection string
    Type       ActionType
    InstanceID string
    Instance   []byte
}

Action represents a data event delivered to a listener.

type ActionType Uses

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 Uses

type Client struct {
    // contains filtered or unexported fields
}

Client provides the client api.

func NewClient Uses

func NewClient(target string, opts ...grpc.DialOption) (*Client, error)

NewClient starts the client.

func (*Client) Close Uses

func (c *Client) Close() error

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

func (*Client) Create Uses

func (c *Client) Create(ctx context.Context, dbID thread.ID, collectionName string, instances Instances, opts ...db.TxnOption) ([]string, error)

Create creates new instances of objects.

func (*Client) Delete Uses

func (c *Client) Delete(ctx context.Context, dbID thread.ID, collectionName string, instanceIDs []string, opts ...db.TxnOption) error

Delete deletes data.

func (*Client) DeleteCollection Uses

func (c *Client) DeleteCollection(ctx context.Context, dbID thread.ID, name string, opts ...db.ManagedOption) error

DeleteCollection deletes a collection.

func (*Client) DeleteDB Uses

func (c *Client) DeleteDB(ctx context.Context, dbID thread.ID, opts ...db.ManagedOption) error

DeleteDB deletes a db.

func (*Client) Find Uses

func (c *Client) Find(ctx context.Context, dbID thread.ID, collectionName string, query *db.Query, dummy interface{}, opts ...db.TxnOption) (interface{}, error)

Find finds instances by query.

func (*Client) FindByID Uses

func (c *Client) FindByID(ctx context.Context, dbID thread.ID, collectionName, instanceID string, instance interface{}, opts ...db.TxnOption) error

FindByID finds an instance by id.

func (*Client) GetCollectionIndexes Uses

func (c *Client) GetCollectionIndexes(ctx context.Context, dbID thread.ID, name string, opts ...db.ManagedOption) ([]db.Index, error)

GetCollectionIndexes returns an existing collection's indexes. Deprecated: Use GetCollectionInfo instead.

func (*Client) GetCollectionInfo Uses

func (c *Client) GetCollectionInfo(ctx context.Context, dbID thread.ID, name string, opts ...db.ManagedOption) (db.CollectionConfig, error)

GetCollectionInfo returns information about an existing collection.

func (*Client) GetDBInfo Uses

func (c *Client) GetDBInfo(ctx context.Context, dbID thread.ID, opts ...db.ManagedOption) (db.Info, error)

GetDBInfo retrives db addresses and keys.

func (*Client) GetToken Uses

func (c *Client) GetToken(ctx context.Context, identity thread.Identity) (tok thread.Token, err error)

GetToken gets a db token for use with the rest of the API.

func (*Client) Has Uses

func (c *Client) Has(ctx context.Context, dbID thread.ID, collectionName string, instanceIDs []string, opts ...db.TxnOption) (bool, error)

Has checks if the specified instances exist.

func (*Client) ListCollections Uses

func (c *Client) ListCollections(ctx context.Context, dbID thread.ID, opts ...db.ManagedOption) ([]db.CollectionConfig, error)

ListCollections returns information about all existing collections.

func (*Client) ListDBs Uses

func (c *Client) ListDBs(ctx context.Context, opts ...db.ManagedOption) (map[thread.ID]db.Info, error)

ListDBs lists all dbs.

func (*Client) Listen Uses

func (c *Client) Listen(ctx context.Context, dbID thread.ID, listenOptions []ListenOption, opts ...db.TxnOption) (<-chan ListenEvent, error)

Listen provides an update whenever the specified db, collection, or instance is updated.

func (*Client) NewCollection Uses

func (c *Client) NewCollection(ctx context.Context, dbID thread.ID, config db.CollectionConfig, opts ...db.ManagedOption) error

NewCollection creates a new collection.

func (*Client) NewDB Uses

func (c *Client) NewDB(ctx context.Context, dbID thread.ID, opts ...db.NewManagedOption) error

NewDB creates a new DB with ID.

func (*Client) NewDBFromAddr Uses

func (c *Client) NewDBFromAddr(ctx context.Context, dbAddr ma.Multiaddr, dbKey thread.Key, opts ...db.NewManagedOption) error

NewDBFromAddr creates a new DB with address and keys.

func (*Client) ReadTransaction Uses

func (c *Client) ReadTransaction(ctx context.Context, dbID thread.ID, collectionName string, opts ...db.TxnOption) (*ReadTransaction, error)

ReadTransaction returns a read transaction that can be started and used and ended.

func (*Client) Save Uses

func (c *Client) Save(ctx context.Context, dbID thread.ID, collectionName string, instances Instances, opts ...db.TxnOption) error

Save saves existing instances.

func (*Client) UpdateCollection Uses

func (c *Client) UpdateCollection(ctx context.Context, dbID thread.ID, config db.CollectionConfig, opts ...db.ManagedOption) error

UpdateCollection updates an existing collection.

func (*Client) Verify Uses

func (c *Client) Verify(ctx context.Context, dbID thread.ID, collectionName string, instances Instances, opts ...db.TxnOption) error

Verify verifies existing instance changes.

func (*Client) WriteTransaction Uses

func (c *Client) WriteTransaction(ctx context.Context, dbID thread.ID, collectionName string, opts ...db.TxnOption) (*WriteTransaction, error)

WriteTransaction returns a read transaction that can be started and used and ended.

type EndTransactionFunc Uses

type EndTransactionFunc = func() error

EndTransactionFunc must be called to end a transaction after it has been started.

type Instances Uses

type Instances []interface{}

Instances is a list of collection instances.

type ListenActionType Uses

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 Uses

type ListenEvent struct {
    Action Action
    Err    error
}

ListenEvent is used to send data or error values for Listen.

type ListenOption Uses

type ListenOption struct {
    Type       ListenActionType
    Collection string
    InstanceID string
}

ListenOption represents a filter to apply when listening for data updates.

type ReadTransaction Uses

type ReadTransaction struct {
    // contains filtered or unexported fields
}

ReadTransaction encapsulates a read transaction.

func (*ReadTransaction) Find Uses

func (t *ReadTransaction) Find(query *db.Query, dummy interface{}) (interface{}, error)

Find finds instances by query.

func (*ReadTransaction) FindByID Uses

func (t *ReadTransaction) FindByID(instanceID string, instance interface{}) error

FindByID gets the instance with the specified ID.

func (*ReadTransaction) Has Uses

func (t *ReadTransaction) Has(instanceIDs ...string) (bool, error)

Has runs a has query in the active transaction.

func (*ReadTransaction) Start Uses

func (t *ReadTransaction) Start() (EndTransactionFunc, error)

Start starts the read transaction.

type WriteTransaction Uses

type WriteTransaction struct {
    // contains filtered or unexported fields
}

WriteTransaction encapsulates a write transaction.

func (*WriteTransaction) Create Uses

func (t *WriteTransaction) Create(items ...interface{}) ([]string, error)

Create creates new instances of objects.

func (*WriteTransaction) Delete Uses

func (t *WriteTransaction) Delete(instanceIDs ...string) error

Delete deletes data.

func (*WriteTransaction) Discard Uses

func (t *WriteTransaction) Discard() error

Discard discards transaction changes.

func (*WriteTransaction) Find Uses

func (t *WriteTransaction) Find(query *db.Query, dummy interface{}) (interface{}, error)

Find finds instances by query.

func (*WriteTransaction) FindByID Uses

func (t *WriteTransaction) FindByID(instanceID string, instance interface{}) error

FindByID gets the instance with the specified ID.

func (*WriteTransaction) Has Uses

func (t *WriteTransaction) Has(instanceIDs ...string) (bool, error)

Has runs a has query in the active transaction.

func (*WriteTransaction) Save Uses

func (t *WriteTransaction) Save(items ...interface{}) error

Save saves existing instances.

func (*WriteTransaction) Start Uses

func (t *WriteTransaction) Start() (EndTransactionFunc, error)

Start starts the write transaction.

func (*WriteTransaction) Verify Uses

func (t *WriteTransaction) Verify(items ...interface{}) error

Verify verifies existing instance changes.

Package client imports 14 packages (graph) and is imported by 8 packages. Updated 2020-11-03. Refresh now. Tools for package owners.