mysql

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// misoconfig-prop: enable MySQL client | false
	PropMySQLEnabled = "mysql.enabled"

	// misoconfig-prop: username | root
	PropMySQLUser = "mysql.user"

	// misoconfig-prop: password
	PropMySQLPassword = "mysql.password"

	// misoconfig-prop: database
	PropMySQLSchema = "mysql.database"

	// misoconfig-prop: host | localhost
	PropMySQLHost = "mysql.host"

	// misoconfig-prop: port | 3306
	PropMySQLPort = "mysql.port"

	// misoconfig-prop: log sql statements | false
	PropMySQLLogSQL = "mysql.log-sql"

	// misoconfig-prop: connection parameters (slices of strings) (see [go-sql-driver/mysql](https://github.com/go-sql-driver/mysql?tab=readme-ov-file#dsn-data-source-name)) | `[]string{"charset=utf8mb4", "parseTime=true", "loc=Local", "readTimeout=30s", "writeTimeout=30s", "timeout=3s", "collation=utf8mb4_general_ci"}`
	PropMySQLConnParam = "mysql.connection.parameters"

	// misoconfig-prop: connection lifetime in minutes (hikari recommends 1800000, so we do the same thing) | 30
	PropMySQLConnLifetime = "mysql.connection.lifetime"

	// misoconfig-prop: max number of open connections | 10
	PropMySQLMaxOpenConns = "mysql.connection.open.max"

	// misoconfig-prop: max number of idle connections | 10
	PropMySQLMaxIdleConns = "mysql.connection.idle.max"
)

misoconfig-section: MySQL Configuration

Variables

This section is empty.

Functions

func AddMySQLBootstrapCallback

func AddMySQLBootstrapCallback(cbk MySQLBootstrapCallback)

func GetMySQL

func GetMySQL() *gorm.DB

Get MySQL Connection.

func InitMySQL

func InitMySQL(rail miso.Rail, p MySQLConnParam) error

Init Handle to the database

If mysql client has been initialized, current func call will be ignored.

func InitMySQLFromProp

func InitMySQLFromProp(rail miso.Rail) error

Init connection to mysql

If mysql client has been initialized, current func call will be ignored.

This func looks for following props:

"mysql.user"
"mysql.password"
"mysql.database"
"mysql.host"
"mysql.port"
"mysql.connection.parameters"

func IsMySQLInitialized

func IsMySQLInitialized() bool

Check whether mysql client is initialized

func NewMySQLConn

func NewMySQLConn(rail miso.Rail, p MySQLConnParam) (*gorm.DB, error)

Create new MySQL connection

Types

type MySQLBootstrapCallback

type MySQLBootstrapCallback func(rail miso.Rail, db *gorm.DB) error

type MySQLConnParam

type MySQLConnParam struct {
	User            string
	Password        string
	Schema          string
	Host            string
	Port            int
	ConnParam       string
	MaxConnLifetime time.Duration
	MaxOpenConns    int
	MaxIdleConns    int
}

Jump to

Keyboard shortcuts

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