bootstrap

package
v0.0.0-...-d8850a5 Latest Latest
Warning

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

Go to latest
Published: May 1, 2023 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

启动

配置信息

mysql

日志

reids

Index

Constants

View Source
const (
	OnlineServiceHostPort = ":50051"
	HttpTimeoutHandler    = 10 * time.Second //TimeoutHandler默认的http超时时间,http响应时间超过后直接返回client端503(不同项目可根据接口最大超时时间调整)
	EnvLocal              = "local"
	EnvTest               = "test"
	EnvBVT                = "bvt"
	EnvProduct            = "product"
	EnvBenchmark          = "benchmark"
)

环境参数

Variables

View Source
var (
	CoreCtx     coreCtx
	DevEnv      string
	TestConfig  string
	ProjectName string
)

变量

Functions

func CheckError

func CheckError(err error, errType string) error

CheckError 验证错误

func ControlCors

func ControlCors() gin.HandlerFunc

ControlCors 设置CORS

func GetConfigByName

func GetConfigByName(filename string) (configList map[string]interface{})

GetConfigByName 通过名称解析yaml

func GetProjectName

func GetProjectName() string

GetProjectName 获取项目名称

func Init

func Init()

Init 初始化:环境、日志等

func InitLogger

func InitLogger()

InitLogger 初始化日志

func InitMysql

func InitMysql()

InitMysql 初始化mysql

func InitRedis

func InitRedis()

InitRedis 初始化redis

func InitWeb

func InitWeb(funs []gin.HandlerFunc) *gin.Engine

InitWeb 初始化http

func LogRecovery

func LogRecovery() gin.HandlerFunc

LogRecovery 恢复日志

func ProjectPath

func ProjectPath() (path string)

ProjectPath 获取项目地址

func RunWeb

func RunWeb(r *gin.Engine, addr string)

RunWeb 启动web服务

func SetLogger

func SetLogger() gin.HandlerFunc

SetLogger 接收gin框架默认的日志

func SetProjectName

func SetProjectName(name string)

SetProjectName 设置项目名称

func Usage

func Usage()

Usage 用法

Types

type Config

type Config struct {
}

type MysqlInstance

type MysqlInstance struct {
	DSN string
	DB  *gorm.DB
}

MysqlInstance mysql对象

func GetMysqlInstance

func GetMysqlInstance(dbName string) (MysqlInstance, error)

GetMysqlInstance 获取数据库连接

type RedisClient

type RedisClient struct {
	Client *redis.Client
}

RedisClient reids客户端对象

Jump to

Keyboard shortcuts

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