1 Star 1 Fork 0

bigbase/pg

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
db_context.go 655 Bytes
一键复制 编辑 原始数据 按行查看 历史
Vladimir Mihailenco 提交于 2017-05-06 14:04 . Add context support
// +build go1.7
package pg
import (
"context"
"github.com/go-pg/pg/internal/pool"
"github.com/go-pg/pg/orm"
)
// DB is a database handle representing a pool of zero or more
// underlying connections. It's safe for concurrent use by multiple
// goroutines.
type DB struct {
opt *Options
pool *pool.ConnPool
fmter orm.Formatter
queryProcessedHooks []queryProcessedHook
ctx context.Context
}
func (db *DB) Context() context.Context {
if db.ctx != nil {
return db.ctx
}
return context.Background()
}
func (db *DB) WithContext(ctx context.Context) *DB {
if ctx == nil {
panic("nil context")
}
cp := *db
cp.ctx = ctx
return &cp
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/bigbase/pg.git
git@gitee.com:bigbase/pg.git
bigbase
pg
pg
v6.4.6

搜索帮助