Documentation
¶
Index ¶
- Constants
- func GetFencePhase(ctx context.Context) enum.FencePhase
- func GetTxName(ctx context.Context) string
- func GetTxStatus(ctx context.Context) *message.GlobalStatus
- func GetXID(ctx context.Context) string
- func InitSeataContext(ctx context.Context) context.Context
- func InitTm(tmConfig TmConfig)
- func IsFenceTxBegin(ctx context.Context) bool
- func IsGlobalTx(ctx context.Context) bool
- func IsSeataContext(ctx context.Context) bool
- func SetBusinessActionContext(ctx context.Context, businessActionContext *BusinessActionContext)
- func SetFencePhase(ctx context.Context, phase enum.FencePhase)
- func SetFenceTxBeginedFlag(ctx context.Context, fenceTxBegined bool)
- func SetTx(ctx context.Context, tx *GlobalTransaction)
- func SetTxName(ctx context.Context, name string)
- func SetTxRole(ctx context.Context, role GlobalTransactionRole)
- func SetTxStatus(ctx context.Context, status message.GlobalStatus)
- func SetXID(ctx context.Context, xid string)
- func SetXIDCopy(ctx context.Context, xid string)
- func UnbindXid(ctx context.Context)
- func WithGlobalTx(ctx context.Context, gc *GtxConfig, business CallbackWithCtx) (re error)
- type BusinessActionContext
- type CallbackWithCtx
- type ContextParam
- type ContextVariable
- type GlobalTransaction
- type GlobalTransactionManager
- type GlobalTransactionRole
- type GtxConfig
- type Propagation
- type ServiceConfig
- type TmConfig
- type TransactionManager
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 GetTxStatus ¶
func GetTxStatus(ctx context.Context) *message.GlobalStatus
func IsFenceTxBegin ¶ added in v1.2.0
func IsGlobalTx ¶
func IsSeataContext ¶
func SetBusinessActionContext ¶
func SetBusinessActionContext(ctx context.Context, businessActionContext *BusinessActionContext)
func SetFencePhase ¶
func SetFencePhase(ctx context.Context, phase enum.FencePhase)
func SetFenceTxBeginedFlag ¶ added in v1.2.0
func SetTx ¶
func SetTx(ctx context.Context, tx *GlobalTransaction)
func SetTxRole ¶
func SetTxRole(ctx context.Context, role GlobalTransactionRole)
func SetTxStatus ¶
func SetTxStatus(ctx context.Context, status message.GlobalStatus)
func SetXIDCopy ¶
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 ¶
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 ¶
Begin a global transaction with given timeout and given name.
func (*GlobalTransactionManager) Commit ¶
func (g *GlobalTransactionManager) Commit(ctx context.Context, gtr *GlobalTransaction) error
Commit the global transaction.
func (*GlobalTransactionManager) Rollback ¶
func (g *GlobalTransactionManager) Rollback(ctx context.Context, gtr *GlobalTransaction) error
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 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 ServiceConfig ¶
type ServiceConfig struct {
VgroupMapping flagext.StringMap `yaml:"vgroup-mapping" json:"vgroup-mapping" koanf:"vgroup-mapping"`
Grouplist flagext.StringMap `yaml:"grouplist" json:"grouplist" koanf:"grouplist"`
EnableDegrade bool `yaml:"enable-degrade" json:"enable-degrade" koanf:"enable-degrade"`
DisableGlobalTransaction bool `yaml:"disable-global-transaction" json:"disable-global-transaction" koanf:"disable-global-transaction"`
}
func (*ServiceConfig) RegisterFlagsWithPrefix ¶
func (cfg *ServiceConfig) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet)
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"`
}
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)
}
Click to show internal directories.
Click to hide internal directories.