common

package
v0.0.0-...-9899e16 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2022 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DtmHttpPort    = 36789
	DtmGrpcPort    = 36790
	DtmMetricsPort = 8889
)

Variables

View Source
var DtmConfig = dtmConfigType{}

DtmConfig 配置

Functions

func GetCallerCodeDir

func GetCallerCodeDir() string

GetCallerCodeDir 获取调用该函数的caller源代码的目录,主要用于测试时,查找相关文件

func GetGinApp

func GetGinApp() *gin.Engine

GetGinApp init and return gin

func MustGetwd

func MustGetwd() string

MustGetwd must version of os.Getwd

func MustLoadConfig

func MustLoadConfig()

func SetDBConn

func SetDBConn(db *DB)

SetDBConn set db connection conf

func WaitDBUp

func WaitDBUp()

WaitDBUp wait for db to go up

func WrapHandler

func WrapHandler(fn func(*gin.Context) (interface{}, error)) gin.HandlerFunc

WrapHandler name is clear

Types

type DB

type DB struct {
	*gorm.DB
}

DB provide more func over gorm.DB

func DbGet

func DbGet(conf map[string]string) *DB

DbGet get db connection for specified conf

func (*DB) Must

func (m *DB) Must() *DB

Must set must flag, panic when error occur

func (*DB) NoMust

func (m *DB) NoMust() *DB

NoMust unset must flag, don't panic when error occur

func (*DB) ToSQLDB

func (m *DB) ToSQLDB() *sql.DB

ToSQLDB get the sql.DB

type MicroService

type MicroService struct {
	Driver   string `yaml:"Driver"`
	Target   string `yaml:"Target"`
	EndPoint string `yaml:"EndPoint"`
}

MicroService config type for micro service

type ModelBase

type ModelBase struct {
	ID         uint64
	CreateTime *time.Time `gorm:"autoCreateTime"`
	UpdateTime *time.Time `gorm:"autoUpdateTime"`
}

ModelBase model base for gorm to provide base fields

Jump to

Keyboard shortcuts

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