mysql

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package mysql define mysql db operation

Index

Constants

View Source
const DefaultLockLeaseAge = 10 * time.Second

DefaultLockLeaseAge define default db locker lease age

Variables

This section is empty.

Functions

func InitDb

func InitDb(user, password, host, port, dbName string, migrateLock bool) (*gorm.DB, error)

InitDb Connect db server and create database if not exists then switch to this database, returns *gorm.DB, error

func InitDbByDsn

func InitDbByDsn(dsn string, migrateLock bool) (*gorm.DB, error)

InitDbByDsn Connect db server by dsn and returns *gorm.DB, error @param dsn @param migrateLock @return *gorm.DB @return error

Types

type Locker

type Locker interface {
	Lock()
	UnLock()
}

Locker db lock

func NewDbLocker

func NewDbLocker(db *gorm.DB, holder string, lease time.Duration) Locker

NewDbLocker new db locker

Jump to

Keyboard shortcuts

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