feat(v2): reconcile Runner 骨架 + 订单级过期清理(超 TTL pending 单/零尝试孤儿单自动关闭)

This commit is contained in:
wangjia
2026-07-10 17:19:38 +08:00
parent aa14204640
commit 6427e8c848
6 changed files with 224 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
package reconcile_test
import (
"context"
"errors"
"testing"
"time"
"github.com/wangjia/pay/internal/reconcile"
)
func TestRunnerRunOnceExecutesAllAndRecoversPanic(t *testing.T) {
r := reconcile.NewRunner()
var a, b int
r.Add("inc-a", time.Minute, func(context.Context) error { a++; return nil })
r.Add("boom", time.Minute, func(context.Context) error { panic("kaboom") }) // 不得拖垮后续
r.Add("inc-b", time.Minute, func(context.Context) error { b++; return errors.New("soft") })
r.RunOnce(context.Background()) // panic 被 recover,error 被记录,均不中断
if a != 1 || b != 1 {
t.Fatalf("a=%d b=%d, want 1/1(panic 任务不应阻断其它)", a, b)
}
}