tm

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnKnow      = GlobalTransactionRole(0)
	Launcher    = GlobalTransactionRole(1)
	Participant = GlobalTransactionRole(2)
)
View Source
const (
	// Required
	// The default propagation.
	// If transaction is existing, execute with current transaction,
	// else execute with beginNewGtx transaction.
	Required = Propagation(0)

	// RequiresNew
	// If transaction is existing, suspend it, and then execute business with beginNewGtx transaction.
	RequiresNew = Propagation(1)

	// NotSupported
	// If transaction is existing, suspend it, and then execute business without transaction.
	NotSupported = Propagation(2)

	// Supports
	// If transaction is not existing, execute without global transaction,
	// else execute business with current transaction.
	Supports = Propagation(3)

	// Never
	// If transaction is existing, throw exception,
	// else execute business without transaction.
	Never = Propagation(4)

	// Mandatory
	// If transaction is not existing, throw exception,
	// else execute business with current transaction.
	Mandatory = Propagation(5)
)

Variables

This section is empty.

Functions

func GetFencePhase

func GetFencePhase(ctx context.Context) enum.FencePhase

func GetTxName

func GetTxName(ctx context.Context) string

func GetTxStatus

func GetTxStatus(ctx context.Context) *message.GlobalStatus

func GetXID

func GetXID(ctx context.Context) string

func InitSeataContext

func InitSeataContext(ctx context.Context) context.Context

func InitTm

func InitTm(tmConfig TmConfig)

func IsFenceTxBegin

func IsFenceTxBegin(ctx context.Context) bool

func IsGlobalTx

func IsGlobalTx(ctx context.Context) bool

func IsSeataContext

func IsSeataContext(ctx context.Context) bool

func SetBusinessActionContext

func SetBusinessActionContext(ctx context.Context, businessActionContext *BusinessActionContext)

func SetFencePhase

func SetFencePhase(ctx context.Context, phase enum.FencePhase)

func SetFenceTxBeginedFlag

func SetFenceTxBeginedFlag(ctx context.Context, fenceTxBegined bool)

func SetTx

func SetTx(ctx context.Context, tx *GlobalTransaction)

func SetTxName

func SetTxName(ctx context.Context, name string)

func SetTxRole

func SetTxRole(ctx context.Context, role GlobalTransactionRole)

func SetTxStatus

func SetTxStatus(ctx context.Context, status message.GlobalStatus)

func SetXID

func SetXID(ctx context.Context, xid string)

func SetXIDCopy

func SetXIDCopy(ctx context.Context, xid string)

func UnbindXid

func UnbindXid(ctx context.Context)

func WithGlobalTx

func WithGlobalTx(ctx context.Context, gc *GtxConfig, business CallbackWithCtx) (re error)

WithGlobalTx begin a global transaction and make it step into committed or rollbacked status.

Types

type BusinessActionContext

type BusinessActionContext struct {
	Xid           string
	BranchId      int64
	ActionName    string
	IsDelayReport bool
	IsUpdated     bool
	ActionContext map[string]interface{}
}

func GetBusinessActionContext

func GetBusinessActionContext(ctx context.Context) *BusinessActionContext

type CallbackWithCtx

type CallbackWithCtx func(ctx context.Context) error

CallbackWithCtx business callback definition

type ContextParam

type ContextParam string

type ContextVariable

type ContextVariable struct {
	FencePhase     enum.FencePhase
	FenceTxBegined bool

	BusinessActionContext *BusinessActionContext
	// GlobalTransaction Represent seata ctx is a global transaction
	GlobalTransaction
}

type GlobalTransaction

type GlobalTransaction struct {
	Xid     string
	XidCopy string
	TxName  string
	// TxStatus Identify a global transaction in a certain status
	TxStatus message.GlobalStatus
	// TxRole Roles in the transaction propagation behavior
	TxRole GlobalTransactionRole
}

func GetTx

func GetTx(ctx context.Context) (tx *GlobalTransaction)

type GlobalTransactionManager

type GlobalTransactionManager struct{}

func GetGlobalTransactionManager

func GetGlobalTransactionManager() *GlobalTransactionManager

func (*GlobalTransactionManager) Begin

func (g *GlobalTransactionManager) Begin(ctx context.Context, timeout time.Duration) error

Begin a global transaction with given timeout and given name.

func (*GlobalTransactionManager) Commit

Commit the global transaction.

func (*GlobalTransactionManager) Rollback

Rollback the global transaction.

type GlobalTransactionRole

type GlobalTransactionRole int8

GlobalTransactionRole Identifies whether a global transaction is beginNewGtx or participates in something else

func GetTxRole

func GetTxRole(ctx context.Context) *GlobalTransactionRole

func (GlobalTransactionRole) String

func (role GlobalTransactionRole) String() string

type GtxConfig

type GtxConfig struct {
	Timeout           time.Duration
	Name              string
	Propagation       Propagation
	LockRetryInternal time.Duration
	LockRetryTimes    int16
}

type Propagation

type Propagation int8

Propagation Used to identify the spread of the global transaction enumerated types

func (Propagation) String

func (p Propagation) String() string

type TmConfig

type TmConfig struct {
	CommitRetryCount                int           `yaml:"commit-retry-count" json:"commit-retry-count" koanf:"commit-retry-count"`
	RollbackRetryCount              int           `yaml:"rollback-retry-count" json:"rollback-retry-count" koanf:"rollback-retry-count"`
	DefaultGlobalTransactionTimeout time.Duration `` /* 136-byte string literal not displayed */
	DegradeCheck                    bool          `yaml:"degrade-check" json:"degrade-check" koanf:"degrade-check"`
	DegradeCheckPeriod              int           `yaml:"degrade-check-period" json:"degrade-check-period" koanf:"degrade-check-period"`
	DegradeCheckAllowTimes          time.Duration `yaml:"degrade-check-allow-times" json:"degrade-check-allow-times" koanf:"degrade-check-allow-times"`
	InterceptorOrder                int           `yaml:"interceptor-order" json:"interceptor-order" koanf:"interceptor-order"`
}

func (*TmConfig) RegisterFlagsWithPrefix

func (cfg *TmConfig) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet)

type TransactionManager

type TransactionManager interface {
	// Begin a new global transaction.
	Begin(applicationId, transactionServiceGroup, name string, timeout int64) (string, error)

	// Commit Global commit.
	Commit(xid string) (message.GlobalStatus, error)

	// Rollback Global rollback.
	Rollback(xid string) (message.GlobalStatus, error)

	// GetStatus Get current status of the give transaction.
	GetStatus(xid string) (message.GlobalStatus, error)

	// GlobalReport Global report.
	GlobalReport(xid string, globalStatus message.GlobalStatus) (message.GlobalStatus, error)
}

Jump to

Keyboard shortcuts

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