extend

package
v0.0.0-...-15bed1d Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDB          = "master"
	DefaultTablePrefix = ""
)
View Source
const (
	TestUserID = "testID"
)

Variables

This section is empty.

Functions

func CloseMockTestT

func CloseMockTestT(ctx context.Context) context.Context

CloseMockTestT 单元测试临时关闭mock

func GetAppLog

func GetAppLog(ctx context.Context) log.Logger

func GetUserClaim

func GetUserClaim(ctx context.Context) *http.Claim

func GetUserDB

func GetUserDB(ctx context.Context) *gorm.DB

func GetUserLog

func GetUserLog(ctx context.Context, logName string) log.Logger

func GetUserRedis

func GetUserRedis(ctx context.Context) redis.RedisClient

func IsMockTest

func IsMockTest(ctx context.Context) (*gomock.Controller, bool)

func MockUniTestT

func MockUniTestT(t *testing.T, testFunc func(context.Context, *gomock.Controller))

MockUniTestT 单元测试 mock 数据

func NewIntegrationTestContext

func NewIntegrationTestContext() context.Context

NewIntegrationTestContext 集成测试连接数据库

func NewUniTestContext

func NewUniTestContext() context.Context

func RedisTablePrefix

func RedisTablePrefix(ctx context.Context) string

func Run

func Run(c *conf.AppConf, route http.RegisterRoute) error

func SetAppState

func SetAppState(ctx context.Context, state *StateFull) context.Context

func ShardDB

func ShardDB(userID string) (string, string, error)

ShardDB 分库分表

Types

type StateFull

type StateFull struct {
	DBs   map[string]*gorm.DB
	Redis map[string]redis.RedisClient
	Logs  map[string]log.Logger
}

func GetAppState

func GetAppState(ctx context.Context) *StateFull

func NewStateFull

func NewStateFull() *StateFull

Jump to

Keyboard shortcuts

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