1 Star 2 Fork 3

kristas/booting-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
def.go 1.03 KB
一键复制 编辑 原始数据 按行查看 历史
kristas 提交于 2021-04-16 18:55 . feat: add casbin
package data
import (
"database/sql"
"gitee.com/kristas/booting-go/framework/core/bean"
)
type Configure interface {
bean.Bean
Config() Config
}
type Config struct {
Type string `yaml:"type"`
Host string `yaml:"host"`
Database string `yaml:"database"`
Username string `yaml:"username"`
Password string `yaml:"password"`
Tunnel string `yaml:"tunnel"`
ConnMaxLifeTime int64 `yaml:"max_life_time"`
ConnMaxIdleTime int64 `yaml:"max_idle_time"`
MaxIdleConns int `yaml:"max_idle_conn"`
MaxOpenConns int `yaml:"max_open_conn"`
}
type DatasourceWrapper interface {
DB() *sql.DB
Configure() Configure
}
func NewDatasourceWrapper(DB *sql.DB, configure Configure) DatasourceWrapper {
return &DatasourceWrapperImpl{
db: DB,
configure: configure,
}
}
type DatasourceWrapperImpl struct {
db *sql.DB
configure Configure
}
func (d *DatasourceWrapperImpl) DB() *sql.DB {
return d.db
}
func (d *DatasourceWrapperImpl) Configure() Configure {
return d.configure
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/kristas/booting-go.git
git@gitee.com:kristas/booting-go.git
kristas
booting-go
booting-go
v1.2.9

搜索帮助