models

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package models 定义数据库 model

Index

Constants

This section is empty.

Variables

View Source
var (
	// DB mysql gorm db client
	DB *gorm.DB
	// Redis redis client
	Redis *redis.Client
)
View Source
var (
	// DefaultMySQLMaxIdleConns db默认最大空闲连接数
	DefaultMySQLMaxIdleConns = 2
	// DefaultMySQLMaxOpenConns db默认最大连接数
	DefaultMySQLMaxOpenConns = 10
	// DefaultMySQLConnMaxLifetime db连接默认可复用的最大时间
	DefaultMySQLConnMaxLifetime = time.Hour
)

Functions

func CheckMySQL

func CheckMySQL(ctx context.Context) map[string]string

CheckMySQL 检查 mysql 服务状态

func CheckRedis

func CheckRedis(ctx context.Context) map[string]string

CheckRedis 检查 redis 服务状态

func Init

func Init()

Init 初始化逻辑

func NewMySQLDB

func NewMySQLDB(c DBConfig) (*gorm.DB, error)

NewMySQLDB 创建gorm mysql db client

Types

type DBConfig

type DBConfig struct {
	// 参考 https://github.com/go-sql-driver/mysql#dsn-data-source-name 获取详情
	// "user:pass@tcp(127.0.0.1:3306)/dbname?charset=utf8mb4&parseTime=True&loc=Local"
	DSN             string
	MaxIdleConns    int
	MaxOpenConns    int
	ConnMaxLifetime time.Duration
	*gorm.Config
}

DBConfig doris相关的配置

Jump to

Keyboard shortcuts

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