table

package
v3.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2021 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSessionPoolClosed is returned by a client instance to indicate
	// that client is closed and not able to complete requested operation.
	ErrSessionPoolClosed = errors.New("ydb: table: build client is closed")

	// ErrSessionPoolOverflow is returned by a client instance to indicate
	// that the client is full and requested operation is not able to complete.
	ErrSessionPoolOverflow = errors.New("ydb: table: build client overflow")

	// ErrSessionUnknown is returned by a client instance to indicate that
	// requested build does not exist within the client.
	ErrSessionUnknown = errors.New("ydb: table: unknown build")

	// ErrNoProgress is returned by a client instance to indicate that
	// operation could not be completed.
	ErrNoProgress = errors.New("ydb: table: no progress")
)
View Source
var (
	ErrNilConnection = errors.New("build with nil connection")
)

Functions

This section is empty.

Types

type Client

type Client interface {
	table.Client

	Get(ctx context.Context) (s Session, err error)
	Take(ctx context.Context, s Session) (took bool, err error)
	Put(ctx context.Context, s Session) (err error)
	Close(ctx context.Context) error
}

func New

func New(ctx context.Context, cluster cluster.Cluster, opts ...config.Option) Client

type Session

type Session interface {
	table.Session

	Close(ctx context.Context) (err error)
	IsClosed() bool
	Status() string
	OnClose(f func(ctx context.Context))
}

type SessionBuilder

type SessionBuilder func(context.Context) (Session, error)

SessionBuilder is the interface that holds logic of creating sessions.

type SessionProvider

type SessionProvider interface {
	// Get returns alive idle build or creates new one.
	Get(context.Context) (Session, error)

	// Put takes no longer needed build for reuse or deletion depending
	// on implementation.
	// Put must be fast, if necessary must be async
	Put(context.Context, Session) (err error)

	// CloseSession provides the most effective way of build closing
	// instead of plain build.Close.
	// CloseSession must be fast. If necessary, can be async.
	CloseSession(ctx context.Context, s Session) error

	// Close provide cleanup sessions
	Close(ctx context.Context) error

	// Do provide the best effort for execute operation
	// Do implements internal busy loop until one of the following conditions is met:
	// - deadline was canceled or deadlined
	// - retry operation returned nil as error
	// Warning: if deadline without deadline or cancellation func Retry will be worked infinite
	Do(ctx context.Context, op table.Operation, opts ...table.Option) (err error)
}

SessionProvider is the interface that holds build lifecycle logic.

func SingleSession

func SingleSession(s Session, b retry.Backoff) SessionProvider

SingleSession returns SessionProvider that uses only given build during retries.

type SessionProviderFunc

type SessionProviderFunc struct {
	OnGet   func(context.Context) (Session, error)
	OnPut   func(context.Context, Session) error
	OnDo    func(context.Context, table.Operation, ...table.Option) error
	OnClose func(context.Context) error
}

func (SessionProviderFunc) Close

func (SessionProviderFunc) CloseSession

func (f SessionProviderFunc) CloseSession(ctx context.Context, s Session) error

func (SessionProviderFunc) Do added in v3.2.1

func (f SessionProviderFunc) Do(ctx context.Context, op table.Operation, opts ...table.Option) (err error)

func (SessionProviderFunc) Get

func (SessionProviderFunc) Put

type Statement

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

Statement is a prepared statement. Like a single build, it is not safe for concurrent use by multiple goroutines.

func (*Statement) Execute

Execute executes prepared data query.

func (*Statement) NumInput

func (s *Statement) NumInput() int

func (*Statement) Text

func (s *Statement) Text() string

type Transaction

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

Transaction is a database transaction. Hence build methods are not goroutine safe, Transaction is not goroutine safe either.

func (*Transaction) CommitTx

func (tx *Transaction) CommitTx(ctx context.Context, opts ...options.CommitTransactionOption) (r resultset.Result, err error)

CommitTx commits specified active transaction.

func (*Transaction) Execute

func (tx *Transaction) Execute(
	ctx context.Context,
	query string, params *table.QueryParameters,
	opts ...options.ExecuteDataQueryOption,
) (r resultset.Result, err error)

Execute executes query represented by text within transaction tx.

func (*Transaction) ExecuteStatement

func (tx *Transaction) ExecuteStatement(
	ctx context.Context,
	stmt table.Statement, params *table.QueryParameters,
	opts ...options.ExecuteDataQueryOption,
) (r resultset.Result, err error)

ExecuteStatement executes prepared statement stmt within transaction tx.

func (*Transaction) ID

func (tx *Transaction) ID() string

func (*Transaction) IsNil

func (tx *Transaction) IsNil() bool

func (*Transaction) Rollback

func (tx *Transaction) Rollback(ctx context.Context) (err error)

Rollback performs a rollback of the specified active transaction.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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