Documentation ¶
Index ¶
- Constants
- Variables
- type Branch
- func (s *Branch) BeginSave()
- func (s *Branch) CanTry() bool
- func (s *Branch) EndSave()
- func (s *Branch) IncrTryCount()
- func (b *Branch) RetryDuration() time.Duration
- func (s *Branch) SetLease(t time.Time)
- func (s *Branch) SetResponse(resp []byte)
- func (s *Branch) SetState(state string)
- func (*Branch) TableName() string
- type ModelStorage
- type RetryConstant
- type RetryStrategy
- type Txn
- type Txns
Constants ¶
View Source
const ( TxnTypeSaga = "saga" TxnTypeTcc = "tcc" BranchTypeCommit = "commit" BranchTypeCompensation = "compensation" BranchTypeConfirm = "confirm" BranchTypeCancel = "cancel" TxnCallTypeSync = "sync" TxnCallTypeAsync = "async" )
Variables ¶
View Source
var ( ErrNotExist = errors.New("not exist") ErrAlreadyExist = errors.New("already exist") ErrIsNotPrepared = errors.New("state of transaction is not prepared") ErrLeaseExpired = errors.New("lease expired") ErrExpired = errors.New("expired") ErrInvalidLessee = errors.New("invalid lessee") ErrNotExpectedState = errors.New("state of transaction is not expected") )
Functions ¶
This section is empty.
Types ¶
type Branch ¶
type Branch struct { Id int64 Gtid string Bid int BranchType string Action string Payload []byte Timeout time.Duration Response []byte Retry RetryStrategy Lease time.Time `gorm:"-"` TryCount int State string UpdatedTime time.Time CreatedTime time.Time // contains filtered or unexported fields }
func (*Branch) IncrTryCount ¶
func (s *Branch) IncrTryCount()
func (*Branch) RetryDuration ¶
func (*Branch) SetResponse ¶
type ModelStorage ¶
type ModelStorage interface { Timeout() time.Duration SetTimeout(t time.Duration) // query Exist(ctx context.Context, gtid string) error GetByGtid(ctx context.Context, gtid string) (*Txn, error) // update Save(ctx context.Context, t *Txn) error Update(ctx context.Context, t *Txn) error UpdateConditions(ctx context.Context, txn *Txn, cb func(oldTxn *Txn) error, returning bool) (*Txn, error) UpdateStateConditions(ctx context.Context, txn *Txn, cb func(oldTxn *Txn) error) (err error) GrantLease(ctx context.Context, txn *Txn, lease time.Duration) error GrantLeaseIncBranchCheckState(ctx context.Context, txn *Txn, branch *Branch, leaseDuration time.Duration, states []string) (err error) // branch UpdateBranch(ctx context.Context, b *Branch) error RegisterBranches(ctx context.Context, bs []*Branch) error // find expired transactions FindRunningLeaseExpired(ctx context.Context, txn string, limit int) ([]*Txn, error) FindPreparedExpired(ctx context.Context, txn string, limit int) ([]*Txn, error) CleanExpiredTxns(ctx context.Context, txn string, untileTime time.Time, limit int) ([]*Txn, error) }
func NewModelStorage ¶
func NewModelStorageMock ¶
func NewModelStorageMock(lessee string) ModelStorage
type RetryConstant ¶
type RetryStrategy ¶
type RetryStrategy struct { MaxRetry int Constant *RetryConstant }
func (*RetryStrategy) Scan ¶
func (rs *RetryStrategy) Scan(value interface{}) error
type Txn ¶
type Txn struct { Id int64 Gtid string Business string State string TxnType string UpdatedTime time.Time CreatedTime time.Time ExpireTime time.Time LeaseExpireTime time.Time Lessee string CallType string NotifyAction string NotifyTimeout time.Duration NotifyRetry time.Duration NotifyCount int Branches []*Branch `gorm:"-" json:"branches,omitempty"` ParallelExecution bool // contains filtered or unexported fields }
func (*Txn) IncrNotify ¶
func (s *Txn) IncrNotify()
func (*Txn) NeedNotify ¶
func (*Txn) SetLeaseExpireTime ¶
Click to show internal directories.
Click to hide internal directories.