Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
MySqlDsnFormat = "%s:%s@tcp(%s:%d)/%s?charset=%s&parseTime=True&loc=Local"
)
View Source
var (
PostgresDsnFormat = "host=%s user=%s password=%s dbname=%s port=%d sslmode=%s TimeZone=%s"
)
View Source
var (
SqlServerDsnFormat = "sqlserver://%s:%s@%s:?%d?database=%s"
)
Functions ¶
This section is empty.
Types ¶
type DbSetting ¶ added in v0.0.3
type DbSetting struct { Common *Common `yaml:"common"` MySql *MySqlSetting `yaml:"mysql"` Postgres *PostgresSetting `yaml:"postgres"` SqlServer *SqlServerSetting `yaml:"sqlServer"` }
type MySqlConnection ¶
type MySqlSetting ¶ added in v0.0.2
type MySqlSetting struct { MaxOpenConns int `yaml:"maxOpenConns"` MaxIdleConns int `yaml:"maxIdleConns"` MaxLifetime int `yaml:"maxLifetime"` MaxIdleTime int `yaml:"maxIdleTime"` Rws bool `yaml:"rws"` Main *MySqlConnection `yaml:"main"` Sources map[string]*MySqlConnection `yaml:"sources"` Replicas map[string]*MySqlConnection `yaml:"replicas"` }
type PostgresConnection ¶ added in v0.0.8
type PostgresPool ¶ added in v0.0.8
type PostgresPool struct {
// contains filtered or unexported fields
}
func NewPostgresPool ¶ added in v0.0.8
func NewPostgresPool(dbSetting *DbSetting) *PostgresPool
NewPostgresPool 创建mysql链接池对象
func (*PostgresPool) Close ¶ added in v0.0.8
func (receiver *PostgresPool) Close() error
Close 关闭数据库链接
func (*PostgresPool) GetConn ¶ added in v0.0.8
func (receiver *PostgresPool) GetConn() *gorm.DB
GetMain 获取主数据库链接
type PostgresSetting ¶ added in v0.0.8
type PostgresSetting struct { MaxOpenConns int `yaml:"maxOpenConns"` MaxIdleConns int `yaml:"maxIdleConns"` MaxLifetime int `yaml:"maxLifetime"` MaxIdleTime int `yaml:"maxIdleTime"` Main *PostgresConnection `yaml:"main"` }
type SqlServerConnection ¶ added in v0.0.8
type SqlServerPool ¶ added in v0.0.8
type SqlServerPool struct {
// contains filtered or unexported fields
}
func NewSqlServerPool ¶ added in v0.0.8
func NewSqlServerPool(dbSetting *DbSetting) *SqlServerPool
NewSqlServerPool 创建mysql链接池对象
func (*SqlServerPool) Close ¶ added in v0.0.8
func (receiver *SqlServerPool) Close() error
Close 关闭数据库链接
func (*SqlServerPool) GetConn ¶ added in v0.0.8
func (receiver *SqlServerPool) GetConn() *gorm.DB
GetMain 获取主数据库链接
type SqlServerSetting ¶ added in v0.0.8
type SqlServerSetting struct { MaxOpenConns int `yaml:"maxOpenConns"` MaxIdleConns int `yaml:"maxIdleConns"` MaxLifetime int `yaml:"maxLifetime"` MaxIdleTime int `yaml:"maxIdleTime"` Main *SqlServerConnection `yaml:"main"` }
Click to show internal directories.
Click to hide internal directories.