Sub2API v1.0 - AI API 网关(二开初始版本,基于上游 Wei-Shaw/sub2api)
Release / update-version (push) Has been cancelled
Release / build-frontend (push) Has been cancelled
Release / release (push) Has been cancelled
Release / sync-version-file (push) Has been cancelled
CI / shell (push) Canceled after 0s
CI / test (push) Canceled after 0s
CI / frontend (push) Canceled after 0s
CI / golangci-lint (push) Canceled after 0s
Security Scan / backend-security (push) Canceled after 0s
Security Scan / frontend-security (push) Canceled after 0s
Release / update-version (push) Has been cancelled
Release / build-frontend (push) Has been cancelled
Release / release (push) Has been cancelled
Release / sync-version-file (push) Has been cancelled
CI / shell (push) Canceled after 0s
CI / test (push) Canceled after 0s
CI / frontend (push) Canceled after 0s
CI / golangci-lint (push) Canceled after 0s
Security Scan / backend-security (push) Canceled after 0s
Security Scan / frontend-security (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package ent
|
||||
|
||||
import "context"
|
||||
|
||||
// WithoutTx 返回一个剥离了所附 *Tx 的 ctx 副本,使调用方可以在基础 client
|
||||
// (autocommit)上执行 best-effort、非关键的副作用,而不加入——也就不会毒化——
|
||||
// 外层事务。
|
||||
//
|
||||
// Postgres 语义:事务内任一语句失败即把整个事务标记为 aborted,后续语句全部被拒,
|
||||
// 直到 ROLLBACK。因此对 fail-open 的副作用(如注册时的默认平台配额快照)必须做事务
|
||||
// 隔离,否则一条无关紧要的写入失败会连累调用方的关键事务。
|
||||
func WithoutTx(ctx context.Context) context.Context {
|
||||
if TxFromContext(ctx) == nil {
|
||||
return ctx
|
||||
}
|
||||
return context.WithValue(ctx, txCtxKey{}, (*Tx)(nil))
|
||||
}
|
||||
Reference in New Issue
Block a user