feat: transaction implement

This commit is contained in:
2026-08-15 02:30:36 +08:00
parent 6515c93378
commit b4e18c6f0c
21 changed files with 3886 additions and 0 deletions
+26
View File
@@ -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
}