client

package
v1.0.0-alpha.8 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Database returns a Database interface for the provided
	// database name.
	//
	// TODO: Return bool/error if the database exists or not
	//       or should the client just get the error when they
	//       try to use it? Latter is more performant.
	Database(name string) Database

	// CreateDatabaseIfNotExist creates a database if it doesn't
	// already exist.
	CreateDatabaseIfNotExist(
		ctx context.Context,
		db string,
		options ...*driver.DatabaseOptions,
	) error
}

Client is the interface for a Tigris client.

func NewClient

func NewClient(
	ctx context.Context,
	url string,
	config *driver.Config,
) (Client, error)

type Database

type Database interface {
	// Transact runs the provided TranactionFunc in a transaction. If the
	// function returns an error then the transaction will be aborted,
	// otherwise it will be comitted.
	Transact(ctx context.Context, fn TxFunc) (interface{}, error)

	// ApplySchemasFromDirectory reads all the files in the provided
	// directory and attempts to apply any files with the .json
	// extension to the database as collection schemas in a single
	// transaction.
	ApplySchemasFromDirectory(ctx context.Context, path string) error
}

Database is the interface for interacting with a specific database in Tigris.

type Tx

type Tx interface {
	driver.CRUDTx
}

Tx is the interface for a client-level transaction. It does not expose operations like Commit()/Abort as it is meant to be used within the Transact() method which abstracts away those operations.

type TxFunc

type TxFunc func(
	ctx context.Context,
	tr Tx,
) (interface{}, error)

TxFunc is a user-provided function that will be run within the context of a tranaction.

Jump to

Keyboard shortcuts

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