xdb

package
v0.0.0-...-d6b644b Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2020 License: MIT Imports: 3 Imported by: 2

Documentation

Overview

Package xdb 获得一个 gorm 的 db client, 虽然 db 客户端会自动重连,但是首次若连接不成功会报错,这里会持续尝试连接。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(config Config) *gorm.DB

New 用配置生成一个 gorm mysql 数据库对象,若目标数据库未启动会一直等待

Types

type Config

type Config struct {
	Host     string `default:"mysql"`
	Port     string `default:"3306"`
	User     string `default:"root"`
	Password string `default:"root"`
	Name     string
	Lifetime int `default:"3000"`
}

Config 数据库配置,可以被主配置直接引用

Jump to

Keyboard shortcuts

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