dtmutil

package
v0.0.0-...-daa3bd9 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 License: MIT Imports: 22 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DefaultHTTPServer default url for http server. used by test and examples
	DefaultHTTPServer = "http://localhost:36789/api/dtmsvr"
	// DefaultJrpcServer default url for http json-rpc server. used by test and examples
	DefaultJrpcServer = "http://localhost:36789/api/json-rpc"
	// 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

func GetSQLDir() string

GetSQLDir get sql scripts dir, used in test

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 WrapHandler

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

WrapHandler used by examples. much more simpler than WrapHandler2

func WrapHandler2

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

WrapHandler2 wrap a function to be the handler of gin request used by dtmsvr

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