dtmutil

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2022 License: BSD-3-Clause Imports: 22 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// DefaultHTTPServer default url for http server. used by test and examples
	DefaultHTTPServer = "http://localhost:36789/api/dtmsvr"
	// DefaultGrpcServer default url for grpc server. used by test and examples
	DefaultGrpcServer = "localhost:36790"
)

Variables

This section is empty.

Functions

func GetGinApp

func GetGinApp() *gin.Engine

GetGinApp init and return gin

func GetNextTime

func GetNextTime(second int64) *time.Time

GetNextTime gets next time from second

func GetSQLDir added in v1.9.1

func GetSQLDir() string

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

func MustGetwd

func MustGetwd() string

MustGetwd must version of os.Getwd

func RecoverPanic

func RecoverPanic(err *error)

RecoverPanic execs recovery operation

func RunSQLScript

func RunSQLScript(conf dtmcli.DBConf, script string, skipDrop bool)

RunSQLScript 1

func WrapHandler2 added in v1.10.0

func WrapHandler2(fn func(*gin.Context) interface{}) gin.HandlerFunc

WrapHandler2 wrap a function te bo the handler of gin request

Types

type DB

type DB struct {
	*gorm.DB
}

DB provide more func over gorm.DB

func DbGet

func DbGet(conf dtmcli.DBConf, ops ...func(*gorm.DB)) *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) ToSQLDB

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

ToSQLDB get the sql.DB

type ModelBase

type ModelBase struct {
	ID         uint64
	CreateTime *time.Time `json:"create_time" gorm:"autoCreateTime"`
	UpdateTime *time.Time `json:"update_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