feat: transaction implement
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package transaction
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrNotFound = errors.New("transaction record not found")
|
||||
ErrActiveExists = errors.New("an unfinished transaction already exists")
|
||||
ErrStepConflict = errors.New("step key already refers to different intent")
|
||||
ErrStepNotPending = errors.New("step is not waiting for an execution result")
|
||||
)
|
||||
|
||||
// ActiveTransactionError 告知调用方当前阻塞新请求的事务。
|
||||
type ActiveTransactionError struct {
|
||||
TransactionID string
|
||||
}
|
||||
|
||||
func (e *ActiveTransactionError) Error() string {
|
||||
return fmt.Sprintf("%s: %s", ErrActiveExists, e.TransactionID)
|
||||
}
|
||||
|
||||
func (e *ActiveTransactionError) Unwrap() error {
|
||||
return ErrActiveExists
|
||||
}
|
||||
Reference in New Issue
Block a user