mysql

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ElementKey = micro.ElementKey("MysqlComponent")

ElementKey is ElementKey for mysql

Functions

func CheckDB

func CheckDB(db *gorm.DB, config Config) error

CheckDB check db

func CreateDB

func CreateDB(config Config) (*gorm.DB, error)

CreateDB create db

func CreateDatabase

func CreateDatabase(config Config) error

CreateDatabase create db

func DropDatabase

func DropDatabase(config Config) error

DropDatabase drop db

func SetDefaultMysqlConfig

func SetDefaultMysqlConfig()

SetDefaultMysqlConfig set default mysql configuration

Types

type Component

type Component struct {
	micro.EmptyComponent
	// contains filtered or unexported fields
}

Component is Component for mysql

func (*Component) Init

func (c *Component) Init(server *micro.Server) error

Init the component

func (*Component) Name

func (c *Component) Name() string

Name of the component

func (*Component) PostStop

func (c *Component) PostStop(ctx context.Context) error

PostStop called after Stop()

func (*Component) PreInit

func (c *Component) PreInit(ctx context.Context) error

PreInit called before Init()

type Config

type Config struct {
	Host         string `toml:"host"`
	Port         int    `toml:"port"`
	DB           string `toml:"db"`
	User         string `toml:"user"`
	Password     string `toml:"password"`
	TimeZone     string `toml:"timeZone"`
	LogMode      bool   `toml:"logmode"`
	MaxOpenConns int    `toml:"maxOpenConns"`
	MaxIdleConns int    `toml:"maxIdleConns"`
}

Config mysql configuration

func GetMysqlConfig

func GetMysqlConfig() *Config

GetMysqlConfig get mysql configuration

Jump to

Keyboard shortcuts

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