mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
fix: version 2.9.2 (#4405)
This commit is contained in:
@ -716,6 +716,13 @@ const (
|
||||
linkPatternDescription = `type:username:password@protocol(host:port)/dbname?param1=value1&...¶mN=valueN`
|
||||
)
|
||||
|
||||
// Context key types to avoid collisions
|
||||
type ctxKey string
|
||||
|
||||
const (
|
||||
ctxKeyWrappedByGetCtxTimeout ctxKey = "WrappedByGetCtxTimeout"
|
||||
)
|
||||
|
||||
type ctxTimeoutType int
|
||||
|
||||
const (
|
||||
|
||||
@ -76,7 +76,7 @@ func (c *Core) GetCtxTimeout(ctx context.Context, timeoutType ctxTimeoutType) (c
|
||||
if ctx == nil {
|
||||
ctx = c.db.GetCtx()
|
||||
} else {
|
||||
ctx = context.WithValue(ctx, "WrappedByGetCtxTimeout", nil)
|
||||
ctx = context.WithValue(ctx, ctxKeyWrappedByGetCtxTimeout, nil)
|
||||
}
|
||||
var config = c.db.GetConfig()
|
||||
switch timeoutType {
|
||||
|
||||
@ -57,10 +57,13 @@ type TxOptions struct {
|
||||
ReadOnly bool
|
||||
}
|
||||
|
||||
// Context key types for transaction to avoid collisions
|
||||
type transactionCtxKey string
|
||||
|
||||
const (
|
||||
transactionPointerPrefix = "transaction"
|
||||
contextTransactionKeyPrefix = "TransactionObjectForGroup_"
|
||||
transactionIdForLoggerCtx = "TransactionId"
|
||||
transactionPointerPrefix = "transaction"
|
||||
contextTransactionKeyPrefix = "TransactionObjectForGroup_"
|
||||
transactionIdForLoggerCtx transactionCtxKey = "TransactionId"
|
||||
)
|
||||
|
||||
var transactionIdGenerator = gtype.NewUint64()
|
||||
@ -286,7 +289,7 @@ func TXFromCtx(ctx context.Context, group string) TX {
|
||||
return nil
|
||||
}
|
||||
|
||||
// transactionKeyForContext forms and returns a string for storing transaction object of certain database group into context.
|
||||
func transactionKeyForContext(group string) string {
|
||||
return contextTransactionKeyPrefix + group
|
||||
// transactionKeyForContext forms and returns a key for storing transaction object of certain database group into context.
|
||||
func transactionKeyForContext(group string) transactionCtxKey {
|
||||
return transactionCtxKey(contextTransactionKeyPrefix + group)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user