package
Version:
v0.5.0
Opens a new window with list of versions in this module.
Published: Nov 2, 2026
License: Apache-2.0
Opens a new window with license information.
Imports: 3
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
Package buntx 是 uow 端口的 bun 实现:事务经 context 传播,repo 适配器
用 Conn(ctx) 取当前连接(事务内=事务连接,否则=根连接)。
Conn 返回 ctx 携带的连接:有事务用事务连接,否则用根数据库。repo 的
一切读写必须经此入口,保证加入调用方的工作单元。
WithTx 把 bun 事务放入 ctx(Run/RunInNewTx 内部使用;测试可直接构造)。
Manager 实现 uow.Runner 与 uow.Isolator(wire 提供,绑定到 uow 端口)。
Run 实现 uow.Runner:已在事务内则加入(同一提交),否则开启新事务。
嵌套传播而非嵌套事务:独立连接上的嵌套事务会因外层持有的锁死锁。
RunInNewTx 实现 uow.Isolator:无视 ctx 已有事务,强制开独立事务并提交
(子操作先于外层提交的路径)。调用方自行确保两事务不触碰互加锁的行。
Source Files
¶
Click to show internal directories.
Click to hide internal directories.