tc

package
v0.0.0-...-1323584 Latest Latest
Warning

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

Go to latest
Published: May 7, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InvalidStatus = errors.New("invalid status")
)

Functions

This section is empty.

Types

type BranchExecutor

type BranchExecutor interface {
	Exec(ctx context.Context, status transaction.Status, branch *transaction.BranchTransaction) error
}

type BranchFunc

type BranchFunc func(ctx context.Context, status transaction.Status, branch *transaction.BranchTransaction) error

func (BranchFunc) Exec

type DurationTimer

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

func NewDurationTimer

func NewDurationTimer(d time.Duration) *DurationTimer

func (*DurationTimer) NextRunTime

func (d *DurationTimer) NextRunTime(t time.Time) int64

type RunTimer

type RunTimer interface {
	NextRunTime(t time.Time) int64
}

type TC

type TC struct {
	RunTimer RunTimer
	Store    store.Store
	BE       map[string]BranchExecutor
	// contains filtered or unexported fields
}

TC 全局事务协调者 处理事务状态转换

func NewTC

func NewTC(rt RunTimer, store store.Store, cnt int) *TC

func (*TC) Abort

func (t *TC) Abort(ctx context.Context, gid string) error

func (*TC) Prepare

func (t *TC) Prepare(ctx context.Context, gt *transaction.GlobalTransaction) error

Prepare 协调者收到prepare请求处理

func (*TC) RegisterBranch

func (t *TC) RegisterBranch(bt *transaction.BranchTransaction) error

func (*TC) RegisterBranchExecutor

func (t *TC) RegisterBranchExecutor(transType string, executor BranchExecutor)

func (*TC) Submit

func (t *TC) Submit(ctx context.Context, gid string) error

Submit 当前状态表示所有prepare通过,可以执行分支事务

type TimerFunc

type TimerFunc func(t time.Time) int64

func (TimerFunc) NextRunTime

func (f TimerFunc) NextRunTime(t time.Time) int64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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