dbconfig

package
v0.0.0-...-64decf6 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdjustDBTimeZone

func AdjustDBTimeZone(config *DBConfig, timeZone string)

AdjustDBTimeZone force adjust session `time_zone`.

Types

type DBConfig

type DBConfig struct {
	Host     string `toml:"host" json:"host" yaml:"host"`
	Port     int    `toml:"port" json:"port" yaml:"port"`
	User     string `toml:"user" json:"user" yaml:"user"`
	Password string `toml:"password" json:"-" yaml:"password"` // omit it for privacy
	// deprecated, mysql driver could automatically fetch this value
	MaxAllowedPacket *int              `toml:"max-allowed-packet" json:"max-allowed-packet" yaml:"max-allowed-packet"`
	Session          map[string]string `toml:"session" json:"session" yaml:"session"`

	// security config
	Security *security.Security `toml:"security" json:"security" yaml:"security"`

	RawDBCfg *RawDBConfig `toml:"-" json:"-" yaml:"-"`
	Net      string       `toml:"-" json:"-" yaml:"-"`
}

DBConfig is the DB configuration.

func (*DBConfig) Adjust

func (db *DBConfig) Adjust()

Adjust adjusts the config.

func (*DBConfig) AdjustWithTimeZone

func (db *DBConfig) AdjustWithTimeZone(timeZone string)

func (*DBConfig) Clone

func (db *DBConfig) Clone() *DBConfig

Clone returns a deep copy of DBConfig. This function only fixes data race when adjusting Session.

func (*DBConfig) Decode

func (db *DBConfig) Decode(data string) error

Decode loads config from file data.

func (*DBConfig) String

func (db *DBConfig) String() string

func (*DBConfig) Toml

func (db *DBConfig) Toml() (string, error)

Toml returns TOML format representation of config.

type RawDBConfig

type RawDBConfig struct {
	MaxIdleConns int
	ReadTimeout  string
	WriteTimeout string
}

RawDBConfig contains some low level database config.

func DefaultRawDBConfig

func DefaultRawDBConfig() *RawDBConfig

DefaultRawDBConfig returns a default raw database config.

func (*RawDBConfig) SetMaxIdleConns

func (c *RawDBConfig) SetMaxIdleConns(value int) *RawDBConfig

SetMaxIdleConns set maxIdleConns for raw database config set value <= 0 then no idle connections are retained. set value > 0 then `value` idle connections are retained.

func (*RawDBConfig) SetReadTimeout

func (c *RawDBConfig) SetReadTimeout(readTimeout string) *RawDBConfig

SetReadTimeout set readTimeout for raw database config.

func (*RawDBConfig) SetWriteTimeout

func (c *RawDBConfig) SetWriteTimeout(writeTimeout string) *RawDBConfig

SetWriteTimeout set writeTimeout for raw database config.

Jump to

Keyboard shortcuts

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