feat: add reusable MySQL outbox and HTTP lifecycle example

This commit is contained in:
2026-09-24 20:54:36 +08:00
parent 0140c78ea7
commit e29dec717f
52 changed files with 2488 additions and 357 deletions

View File

@@ -0,0 +1,19 @@
package outbox
import (
"context"
"database/sql"
orbit "git.yuntuo.hk/k2safe/orbit/sdk/go"
)
// AcceptedHook 在最新租约确认事务内关联业务数据;可能在事务回滚/提交不明后再次调用。
// 必须同库、幂等、遵守 context,只做短 SQL;不能 Commit/Rollback,也不能发网络请求。
// record 是锁定后的发送记录,receipt 是本次已核验的受理回执,不是任务完成结果。
type AcceptedHook func(context.Context, *sql.Tx, Record, orbit.SubmitTaskResult) error
// Options 在构造后固定,Store 可以在多个发送 goroutine 中复用。
type Options struct {
// OnAccepted 可选的业务关联;为空时受理关系仅保存在 Outbox 的 TaskID/ReceiptJSON。
OnAccepted AcceptedHook
}