session

package
v1.1.0-beta.0...-e54cc5b Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MockDDLOnce is only used for test.
	MockDDLOnce = int64(0)
	// TestNotifyBeginTxnCh is used for if the txn is beginning in RunInTxn.
	TestNotifyBeginTxnCh = make(chan struct{})
)

Functions

This section is empty.

Types

type Pool

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

Pool is used to new Session.

func NewSessionPool

func NewSessionPool(resPool *pools.ResourcePool) *Pool

NewSessionPool creates a new Session pool.

func (*Pool) Close

func (sg *Pool) Close()

Close clean up the Pool.

func (*Pool) Get

func (sg *Pool) Get() (sessionctx.Context, error)

Get gets sessionCtx from context resource pool. Please remember to call Put after you finished using sessionCtx.

func (*Pool) Put

func (sg *Pool) Put(ctx sessionctx.Context)

Put returns sessionCtx to context resource pool.

type Session

type Session struct {
	sessionctx.Context
}

Session wraps sessionctx.Context for transaction usage.

func NewSession

func NewSession(s sessionctx.Context) *Session

NewSession creates a new Session.

func (*Session) Begin

func (s *Session) Begin(ctx context.Context) error

Begin starts a transaction.

func (*Session) Commit

func (s *Session) Commit(ctx context.Context) error

Commit commits the transaction.

func (*Session) Execute

func (s *Session) Execute(ctx context.Context, query string, label string, args ...any) ([]chunk.Row, error)

Execute executes a query.

func (*Session) Reset

func (s *Session) Reset()

Reset resets the session.

func (*Session) Rollback

func (s *Session) Rollback()

Rollback aborts the transaction.

func (*Session) RunInTxn

func (s *Session) RunInTxn(f func(*Session) error) (err error)

RunInTxn runs a function in a transaction.

func (*Session) Session

func (s *Session) Session() sessionctx.Context

Session returns the sessionctx.Context.

func (*Session) Txn

func (s *Session) Txn() (kv.Transaction, error)

Txn activate and returns the current transaction.

Jump to

Keyboard shortcuts

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