package tx

import "github.com/ydb-platform/ydb-go-sdk/v3/internal/tx"

Index

Constants

const (
	LazyTxID = "LAZY_TX"
	FakeTxID = "FAKE_TX"
)

Functions

func BeginTx

func BeginTx(opts ...SettingsOption) beginTxOptions

BeginTx returns selector transaction control option

func WithOnlineReadOnly

func WithOnlineReadOnly(opts ...OnlineReadOnlyOption) onlineReadOnlySettingsOption

func WithTx

func WithTx(t Identifier) txIDTxControlOption

func WithTxControl

func WithTxControl(ctx context.Context, txControl *Control) context.Context

func WithTxControlHook

func WithTxControlHook(ctx context.Context, hook txControlHook) context.Context

func WithTxID

func WithTxID(txID string) txIDTxControlOption

Types

type Control

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

func ControlFromContext

func ControlFromContext(ctx context.Context, defaultTxControl *Control) (txControl *Control)

func DefaultTxControl

func DefaultTxControl() *Control

DefaultTxControl returns default transaction control with serializable read-write isolation mode and auto-commit

func NewControl

func NewControl(opts ...ControlOption) *Control

NewControl makes transaction control from given options

func NoTx

func NoTx() *Control

func OnlineReadOnlyTxControl

func OnlineReadOnlyTxControl(opts ...OnlineReadOnlyOption) *Control

OnlineReadOnlyTxControl returns online read-only transaction control

func SerializableReadWriteTxControl

func SerializableReadWriteTxControl(opts ...ControlOption) *Control

SerializableReadWriteTxControl returns transaction control with serializable read-write isolation mode

func SnapshotReadOnlyTxControl

func SnapshotReadOnlyTxControl() *Control

SnapshotReadOnlyTxControl returns snapshot read-only transaction control

func StaleReadOnlyTxControl

func StaleReadOnlyTxControl() *Control

StaleReadOnlyTxControl returns stale read-only transaction control

func WithCommit

func WithCommit(ctrl *Control) *Control

func (*Control) Commit

func (ctrl *Control) Commit() bool

func (*Control) Selector

func (ctrl *Control) Selector() Selector

func (*Control) ToYdbQueryTransactionControl

func (ctrl *Control) ToYdbQueryTransactionControl(a *allocator.Allocator) *Ydb_Query.TransactionControl

func (*Control) ToYdbTableTransactionControl

func (ctrl *Control) ToYdbTableTransactionControl(a *allocator.Allocator) *Ydb_Table.TransactionControl

type ControlOption

type ControlOption interface {
	// contains filtered or unexported methods
}

func CommitTx

func CommitTx() ControlOption

CommitTx returns commit transaction control option

type Identifier

type Identifier interface {
	ID() string
	// contains filtered or unexported methods
}

type LazyID

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

func ID

func ID(id string) LazyID

func (LazyID) ID

func (id LazyID) ID() string

func (*LazyID) SetTxID

func (id *LazyID) SetTxID(txID string)

type OnTransactionBeforeCommit

type OnTransactionBeforeCommit func(ctx context.Context) error

type OnTransactionCompletedFunc

type OnTransactionCompletedFunc func(transactionResult error)

type OnlineReadOnlyOption

type OnlineReadOnlyOption interface {
	// contains filtered or unexported methods
}

func WithInconsistentReads

func WithInconsistentReads() OnlineReadOnlyOption

type Selector

type Selector interface {
	// contains filtered or unexported methods
}

type Settings

type Settings []SettingsOption

Transaction settings options

func NewSettings

func NewSettings(opts ...SettingsOption) Settings

NewSettings returns transaction settings

func (Settings) ToYdbQuerySettings

func (opts Settings) ToYdbQuerySettings(a *allocator.Allocator) *Ydb_Query.TransactionSettings

func (Settings) ToYdbTableSettings

func (opts Settings) ToYdbTableSettings(a *allocator.Allocator) *Ydb_Table.TransactionSettings

type SettingsOption

type SettingsOption interface {
	ApplyQueryTxSettingsOption(a *allocator.Allocator, txSettings *Ydb_Query.TransactionSettings)
	ApplyTableTxSettingsOption(a *allocator.Allocator, txSettings *Ydb_Table.TransactionSettings)
}

Transaction settings options

func WithDefaultTxMode

func WithDefaultTxMode() SettingsOption

func WithSerializableReadWrite

func WithSerializableReadWrite() SettingsOption

func WithSnapshotReadOnly

func WithSnapshotReadOnly() SettingsOption

func WithStaleReadOnly

func WithStaleReadOnly() SettingsOption

type Transaction

type Transaction interface {
	Identifier
	UnLazy(ctx context.Context) error
	SessionID() string

	// OnBeforeCommit add callback, which will be called before commit transaction
	// the method will be not call the method if some error happen and transaction will not be committed
	OnBeforeCommit(f OnTransactionBeforeCommit)
	OnCompleted(f OnTransactionCompletedFunc)
	Rollback(ctx context.Context) error
}

func AsTransaction

func AsTransaction(id Identifier) (Transaction, error)

Source Files

context.go control.go id.go settings.go transaction.go

Version
v3.105.2
Published
Apr 3, 2025
Platform
js/wasm
Imports
6 packages
Last checked
5 minutes ago

Tools for package owners.