runtime

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2023 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Overview

Package runtime is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var Tracer = otel.Tracer("Runtime")

Functions

func NumOfStateBranchTx

func NumOfStateBranchTx(state TxState, tx CompositeTx) int32

func Register

func Register(tenant string, schema string, rt Runtime) error

Register registers a Runtime.

func Unload

func Unload(tenant, schema string) error

Unload unloads a Runtime, here schema means logical database name.

Types

type AtomDB

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

AtomDB represents an atom physical database instance

func NewAtomDB

func NewAtomDB(node *config.Node) *AtomDB

func (*AtomDB) Call

func (db *AtomDB) Call(ctx context.Context, sql string, args ...proto.Value) (res proto.Result, warn uint16, err error)

func (*AtomDB) CallFieldList

func (db *AtomDB) CallFieldList(ctx context.Context, table, wildcard string) ([]proto.Field, error)

func (*AtomDB) Capacity

func (db *AtomDB) Capacity() int

func (*AtomDB) Close

func (db *AtomDB) Close() error

func (*AtomDB) ID

func (db *AtomDB) ID() string

func (*AtomDB) IdleTimeout

func (db *AtomDB) IdleTimeout() time.Duration

func (*AtomDB) MaxCapacity

func (db *AtomDB) MaxCapacity() int

func (*AtomDB) NodeConn

func (db *AtomDB) NodeConn() proto.NodeConn

func (*AtomDB) SetCapacity

func (db *AtomDB) SetCapacity(capacity int) error

func (*AtomDB) SetIdleTimeout

func (db *AtomDB) SetIdleTimeout(idleTimeout time.Duration) error

func (*AtomDB) SetMaxCapacity

func (db *AtomDB) SetMaxCapacity(maxCapacity int) error

func (*AtomDB) SetWeight

func (db *AtomDB) SetWeight(weight proto.Weight) error

func (*AtomDB) Variable

func (db *AtomDB) Variable(ctx context.Context, name string) (interface{}, error)

func (*AtomDB) Weight

func (db *AtomDB) Weight() proto.Weight

type BackendResourcePool

type BackendResourcePool pools.ResourcePool

func (*BackendResourcePool) Get

Get will return the next available resource and convert to mysql.BackendConnection. If available less than 1, it will make capacity increase by 1. If the net connection check failure, it will take again.

type BranchTx

type BranchTx interface {
	// SetPrepareFunc sets prepare dbFunc
	SetPrepareFunc(f dbFunc)
	// SetCommitFunc sets commit dbFunc
	SetCommitFunc(f dbFunc)
	// SetRollbackFunc sets rollback dbFunc
	SetRollbackFunc(f dbFunc)
	// GetConn gets mysql connection
	GetConn() *mysql.BackendConnection
	// GetTxState get cur tx state
	GetTxState() TxState
	// Commit commit tx
	Commit(ctx context.Context) (res proto.Result, warn uint16, err error)
	// Rollback rollback tx
	Rollback(ctx context.Context) (proto.Result, uint16, error)
}

BranchTx each atomDB transaction

type CompositeTx

type CompositeTx interface {
	// GetTrxID get cur tx id
	GetTrxID() string
	// GetTenant get cur tx owner tenant
	GetTenant() string
	// GetTxState get cur tx state
	GetTxState() TxState
	// SetBeginFunc sets begin func
	SetBeginFunc(f dbFunc)
	// Range range branchTx map
	Range(func(tx BranchTx))
	// Commit commit tx
	Commit(ctx context.Context) (res proto.Result, warn uint16, err error)
	// Rollback rollback tx
	Rollback(ctx context.Context) (proto.Result, uint16, error)
}

CompositeTx distribute transaction

type DeadLockDog

type DeadLockDog interface {
	// Start run deadlock detection dog, can set how long the delay starts to execute
	Start(ctx context.Context, delay time.Duration, tx CompositeTx)
	// HasDeadLock tx deadlock is occur
	HasDeadLock() bool
	// Cancel stop run deadlock detection dog
	Cancel()
}

DeadLockDog check target CompositeTx has deadlock

type MockRuntime

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

MockRuntime is a mock of Runtime interface.

func NewMockRuntime

func NewMockRuntime(ctrl *gomock.Controller) *MockRuntime

NewMockRuntime creates a new mock instance.

func (*MockRuntime) Begin

func (m *MockRuntime) Begin(arg0 context.Context, arg1 ...TxHook) (proto.Tx, error)

Begin mocks base method.

func (*MockRuntime) EXPECT

func (m *MockRuntime) EXPECT() *MockRuntimeMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockRuntime) Exec

func (m *MockRuntime) Exec(arg0 context.Context, arg1, arg2 string, arg3 ...proto.Value) (proto.Result, error)

Exec mocks base method.

func (*MockRuntime) Execute

func (m *MockRuntime) Execute(arg0 *proto.Context) (proto.Result, uint16, error)

Execute mocks base method.

func (*MockRuntime) Namespace

func (m *MockRuntime) Namespace() *namespace.Namespace

Namespace mocks base method.

func (*MockRuntime) Query

func (m *MockRuntime) Query(arg0 context.Context, arg1, arg2 string, arg3 ...proto.Value) (proto.Result, error)

Query mocks base method.

type MockRuntimeMockRecorder

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

MockRuntimeMockRecorder is the mock recorder for MockRuntime.

func (*MockRuntimeMockRecorder) Begin

func (mr *MockRuntimeMockRecorder) Begin(arg0 interface{}, arg1 ...interface{}) *gomock.Call

Begin indicates an expected call of Begin.

func (*MockRuntimeMockRecorder) Exec

func (mr *MockRuntimeMockRecorder) Exec(arg0, arg1, arg2 interface{}, arg3 ...interface{}) *gomock.Call

Exec indicates an expected call of Exec.

func (*MockRuntimeMockRecorder) Execute

func (mr *MockRuntimeMockRecorder) Execute(arg0 interface{}) *gomock.Call

Execute indicates an expected call of Execute.

func (*MockRuntimeMockRecorder) Namespace

func (mr *MockRuntimeMockRecorder) Namespace() *gomock.Call

Namespace indicates an expected call of Namespace.

func (*MockRuntimeMockRecorder) Query

func (mr *MockRuntimeMockRecorder) Query(arg0, arg1, arg2 interface{}, arg3 ...interface{}) *gomock.Call

Query indicates an expected call of Query.

type Runtime

type Runtime interface {
	proto.Executable
	proto.VConn
	// Namespace returns the namespace.
	Namespace() *namespace.Namespace
	// Begin begins a new transaction.
	Begin(ctx context.Context, hooks ...TxHook) (proto.Tx, error)
}

Runtime executes a sql statement.

func Load

func Load(tenant, schema string) (Runtime, error)

Load loads a Runtime, here schema means logical database name.

type TxHook

type TxHook interface {
	// OnTxStateChange Fired when CompositeTx TrxState change
	OnTxStateChange(ctx context.Context, state TxState, tx CompositeTx) error
	// OnCreateBranchTx Fired when BranchTx create
	OnCreateBranchTx(ctx context.Context, tx BranchTx)
}

TxHook transaction hook

type TxState

type TxState int32

TxState Transaction status

const (
	TrxActive     TxState // CompositeTx Default state
	TrxPreparing          // Start executing the first SQL statement
	TrxPrepared           // All SQL statements are executed, and before the Commit statement executes
	TrxCommitting         // After preparing is completed, ready to start execution
	TrxCommitted          // Officially complete the Commit action
	TrxAborting           // There are abnormalities during the execution of the branch, and the composite transaction is prohibited to continue to execute
	TrxRollback
	TrxFinish
	TrxRolledBack
)

Directories

Path Synopsis
Package function provides a set of mysql functions implements by Golang.
Package function provides a set of mysql functions implements by Golang.
dal
ddl
dml
dal
ddl
dml

Jump to

Keyboard shortcuts

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