gormPool

package
v0.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

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 Common added in v0.0.3

type Common struct {
	Driver string `yaml:"driver"`
}

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"`
}

func NewDbSetting added in v0.0.3

func NewDbSetting(path string) *DbSetting

NewDbSetting 初始化

type Dsn

type Dsn struct {
	Name    string
	Content string
}

type MySqlConnection

type MySqlConnection struct {
	Username  string `yaml:"username"`
	Password  string `yaml:"password"`
	Host      string `yaml:"host"`
	Port      uint16 `yaml:"port"`
	Database  string `yaml:"database"`
	Charset   string `yaml:"charset"`
	Collation string `yaml:"collation"`
}

type MySqlPool

type MySqlPool struct {
	// contains filtered or unexported fields
}

func NewMySqlPool

func NewMySqlPool(dbSetting *DbSetting) *MySqlPool

NewMySqlPool 创建mysql链接池对象

func (*MySqlPool) Close added in v0.0.2

func (receiver *MySqlPool) Close() error

Close 关闭数据库链接

func (*MySqlPool) GetConn added in v0.0.6

func (receiver *MySqlPool) GetConn() *gorm.DB

GetMain 获取主数据库链接

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 PostgresConnection struct {
	Username string `yaml:"username"`
	Password string `yaml:"password"`
	Host     string `yaml:"host"`
	Port     uint16 `yaml:"port"`
	Database string `yaml:"database"`
	TimeZone string `yaml:"timezone"`
	SslMode  string `yaml:"sslmode"`
}

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 SqlServerConnection struct {
	Username string `yaml:"username"`
	Password string `yaml:"password"`
	Host     string `yaml:"host"`
	Port     uint16 `yaml:"port"`
	Database string `yaml:"database"`
}

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"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL