xydb

package
v0.0.0-...-76b3090 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 25 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToTemporalError

func ConvertToTemporalError(operation string, err error, details ...string) error

func EnsureOneRowCursor

func EnsureOneRowCursor(ctx context.Context, res result.Result) error

func IsPreconditionFailedAndContains

func IsPreconditionFailedAndContains(err error, substr string) bool

func NewRootCauseError

func NewRootCauseError(new func(message string) error, message string) error

func OnlineReadOnlyTxControl

func OnlineReadOnlyTxControl(opts ...table.TxOnlineReadOnlyOption) *table.TransactionControl

func SnapshotReadOnlyTxControl

func SnapshotReadOnlyTxControl(opts ...table.TxOnlineReadOnlyOption) *table.TransactionControl

func WrapErrorAsRootCause

func WrapErrorAsRootCause(err error) error

Types

type Client

type Client struct {
	DB       *ydb.Driver
	Database string
	Folder   string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ctx context.Context, config Config, logger tlog.Logger, mh metrics.Handler) (
	*Client,
	error,
)

func (*Client) AddQueryPrefix

func (client *Client) AddQueryPrefix(query string) string

func (*Client) Close

func (client *Client) Close(ctx context.Context) error

func (*Client) Do

func (client *Client) Do(
	ctx context.Context,
	query string,
	tx *table.TransactionControl,
	params *table.QueryParameters,
	opts ...table.Option,
) (res result.Result, err error)

func (*Client) Do2

func (client *Client) Do2(
	ctx context.Context,
	query string,
	tx *table.TransactionControl,
	getQueryParameters func() *table.QueryParameters,
	opts ...table.Option,
) (res result.Result, err error)

func (*Client) DoSchema

func (client *Client) DoSchema(
	ctx context.Context,
	query string,
	params ...options.ExecuteSchemeQueryOption,
) (err error)

func (*Client) GetPrefix

func (client *Client) GetPrefix() string

func (*Client) Write

func (client *Client) Write(
	ctx context.Context,
	query string,
	params *table.QueryParameters,
	opts ...table.Option,
) error

func (*Client) Write2

func (client *Client) Write2(
	ctx context.Context,
	query string,
	getQueryParameters func() *table.QueryParameters,
	opts ...table.Option,
) error

type Config

type Config struct {
	Endpoint             string `yaml:"endpoint"`
	Database             string `yaml:"database"`
	Folder               string `yaml:"folder"`
	Token                string `yaml:"token"`
	UseSSL               bool   `yaml:"use_ssl"`
	SessionPoolSizeLimit int    `yaml:"pool_size_limit"`
	PreferLocalDC        bool   `yaml:"prefer_local_dc"`
}

func (*Config) Validate

func (c *Config) Validate() (bool, error)

type Executor

type Executor interface {
	Execute(
		ctx context.Context,
		query string,
		params *table.QueryParameters,
	) (result.Result, error)

	// Write is a special case of Execute that immediately closes its result.
	Write(
		ctx context.Context,
		query string,
		params *table.QueryParameters,
	) error
}

Executor is a very primitive wrapper that provides the same interface for executing queries in either session or transaction.

Allows having helper functions that could be used in both cases.

func NewExecutorFromSession

func NewExecutorFromSession(s table.Session, tx *table.TransactionControl) Executor

func NewExecutorFromTransactionActor

func NewExecutorFromTransactionActor(a table.TransactionActor) Executor

type QueryConstructor

type QueryConstructor struct {
	Declaration []string
	Queries     []string
}

func NewQuery

func NewQuery() *QueryConstructor

func (*QueryConstructor) AddQuery

func (b *QueryConstructor) AddQuery(query string)

func (*QueryConstructor) Declare

func (b *QueryConstructor) Declare(name string, t types.Type)

type RootCauseError

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

func (*RootCauseError) Error

func (e *RootCauseError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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