mysql

package
v0.0.0-...-05d1b2a Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	Silent = "silent"
	Warn   = "warn"
	Error  = "error"
	Info   = "info"
)

Variables

View Source
var (
	Default = "default"
)

Functions

func Connect

func Connect(opts ...Option) error

func GetDB

func GetDB(ctx context.Context, name ...string) *gorm.DB

Types

type Config

type Config struct {
	MySQL []Options `json:"mysql"`
}

func (Config) Close

func (c Config) Close() error

func (Config) Init

func (c Config) Init() error

type Option

type Option func(*Options)

func Database

func Database(database string) Option

func Host

func Host(host string) Option

func LogLevel

func LogLevel(level string) Option

func MaxIdleConn

func MaxIdleConn(num int) Option

func MaxLifeTime

func MaxLifeTime(t int32) Option

func MaxOpenConn

func MaxOpenConn(num int) Option

func Metrics

func Metrics(b bool) Option

func Name

func Name(name string) Option

func Password

func Password(password string) Option

func Port

func Port(port int32) Option

func Trace

func Trace(b bool) Option

func Username

func Username(username string) Option

type Options

type Options struct {
	Name        string `json:"name" mapstructure:"name"`
	Host        string `json:"host" mapstructure:"host"`
	Port        int32  `json:"port" mapstructure:"port"`
	Username    string `json:"username" mapstructure:"username"`
	Password    string `json:"password" mapstructure:"password"`
	Database    string `json:"database" mapstructure:"database"`
	MaxIdleConn int    `json:"max_idle_conn" mapstructure:"max_idle_conn"`
	MaxOpenConn int    `json:"max_open_conn" mapstructure:"max_open_conn"`
	LogLevel    string `json:"log_level" mapstructure:"log_level"`
	MaxLifeTime int32  `json:"max_life_time" mapstructure:"max_life_time"`
	Metrics     bool   `json:"metrics" mapstructure:"metrics"`
	Trace       bool   `json:"trace" mapstructure:"trace"`
}

func GetConfig

func GetConfig(name ...string) Options

func NewOptions

func NewOptions(opts ...Option) Options

Jump to

Keyboard shortcuts

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