1 Star 2 Fork 3

kristas/booting-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
datsource.go 2.03 KB
一键复制 编辑 原始数据 按行查看 历史
kristas 提交于 2021-06-25 16:51 . refactor
package data
import (
"gitee.com/kristas/booting-go/framework/core/bean"
"gitee.com/kristas/booting-go/framework/core/component"
)
type Datasource interface {
bean.Bean
component.ConfigurationProperties
GetType() string
GetHost() string
GetDatabase() string
GetUsername() string
GetPassword() string
GetTunnel() string
GetConnMaxLifeTime() int64
GetConnMaxIdleTime() int64
GetMaxIdleConns() int
GetMaxOpenConns() int
IsLazyFetch() bool
}
type DatasourceConfig struct {
BeanName string
PropertiesPrefix string
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"`
LazyFetch bool `yaml:"lazy_fetch"`
}
func (d *DatasourceConfig) Bean() string {
return presentDefault(d.BeanName, "datasource")
}
func (d *DatasourceConfig) Prefix() string {
return presentDefault(d.PropertiesPrefix, "application.datasource")
}
func (d *DatasourceConfig) GetType() string {
return d.Type
}
func (d *DatasourceConfig) GetHost() string {
return d.Host
}
func (d *DatasourceConfig) GetDatabase() string {
return d.Database
}
func (d *DatasourceConfig) GetUsername() string {
return d.Username
}
func (d *DatasourceConfig) GetPassword() string {
return d.Password
}
func (d *DatasourceConfig) GetTunnel() string {
return d.Tunnel
}
func (d *DatasourceConfig) GetConnMaxLifeTime() int64 {
return d.ConnMaxLifeTime
}
func (d *DatasourceConfig) GetConnMaxIdleTime() int64 {
return d.ConnMaxIdleTime
}
func (d *DatasourceConfig) GetMaxIdleConns() int {
return d.MaxIdleConns
}
func (d *DatasourceConfig) GetMaxOpenConns() int {
return d.MaxOpenConns
}
func (d *DatasourceConfig) IsLazyFetch() bool {
return d.LazyFetch
}
func presentDefault(s, defaults string) string {
if s == "" {
s = defaults
}
return s
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/kristas/booting-go.git
git@gitee.com:kristas/booting-go.git
kristas
booting-go
booting-go
v1.3.5

搜索帮助