gormKit

package
v3.0.73 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open added in v3.0.28

func Open(dialector gorm.Dialector, poolConfig *PoolConfig, options ...gorm.Option) (*gorm.DB, error)

Open 返回一个 *gorm.DB 实例.

@param options (1) 可以为nil(将采用默认值)

(2) 建议配置 gorm.Config.Logger,配置日志输出

Types

type PoolConfig

type PoolConfig struct {
	// MaxIdleConns <=0: no idle connections
	MaxIdleConns int `json:"maxIdleConns" yaml:"maxIdleConns"`

	// MaxOpenConns <= 0: there is no limit on the number of open connections
	MaxOpenConns int `json:"maxOpenConns" yaml:"maxOpenConns"`

	// ConnMaxLifetime <= 0: connections are not closed due to a connection's age
	ConnMaxLifetime time.Duration `json:"connMaxLifetime" yaml:"connMaxLifetime"`
}

func (*PoolConfig) TakeEffect added in v3.0.29

func (pc *PoolConfig) TakeEffect(sqlDB *sql.DB)

TakeEffect 使连接池配置生效.

Jump to

Keyboard shortcuts

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