config

package
v1.3.28 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvDev  = "dev"
	EnvTest = "test"
	EnvPro  = "pro"
)
View Source
const (
	ConfigFileName        = "config_origin.yaml"
	ConfigEncryptFileName = "config.yaml"
)
View Source
const BaseKey = "oSTP7QSjwvzQAtbI"

Variables

View Source
var Container *dig.Container

Functions

This section is empty.

Types

type Config

type Config struct {
	Project  string                   `yaml:"project"`
	Env      string                   `yaml:"env"`
	LogLevel int8                     `yaml:"logLevel"` //全局日志等级
	Gorm     map[string]Gorm          `yaml:"gorm"`
	Redis    map[string]redisd.Config `yaml:"redis"`
	Grpc     map[string]Grpc          `yaml:"grpc"`
	Web      map[string]*Web          `yaml:"web"`
	Attach   interface{}              `yaml:"attach"` //附加配置 用户定义
}

Config 配置参数

func (*Config) BindAttachType added in v1.3.5

func (c *Config) BindAttachType(dst any) (Config, error)

func (*Config) PrintProjectInfo

func (conf *Config) PrintProjectInfo()

type ConfigFile

type ConfigFile struct {
	Secret       string `yaml:"secret"`
	SecretConfig string `yaml:"secretConfig"`
}

type Gorm

type Gorm struct {
	Debug         bool       `yaml:"debug"`
	LogLvl        int        `yaml:"logLvl"`
	SlowThreshold int        `yaml:"slowThreshold"`
	MaxLifetime   int        `yaml:"maxLifeTime"`
	MaxOpenConns  int        `yaml:"maxOpenConns"`
	MaxIdleConns  int        `yaml:"maxIdleConns"`
	Driver        GormDriver `json:"driver"`
	MySQL         MySQL      `yaml:"mysql"`
}

Gorm gorm配置参数

type GormDriver

type GormDriver string
const (
	Mysql GormDriver = "mysql"
)

type Grpc

type Grpc struct {
	Host      string              `yaml:"host"`
	Port      int32               `yaml:"port"`
	WhiteList map[string][]string `yaml:"whiteList"` //白名单
}

func (Grpc) Address

func (g Grpc) Address() string

type MySQL

type MySQL struct {
	Host       string       `yaml:"host"`
	Port       int          `yaml:"port"`
	User       string       `yaml:"user"`
	Password   string       `yaml:"password"`
	DBName     string       `yaml:"dbName"`
	Parameters string       `yaml:"parameters"`
	Variant    MysqlVariant `yaml:"variant"` //mysql变种
}

MySQL mysql配置参数

func (MySQL) DSN

func (a MySQL) DSN() string

DSN 数据库连接串

type MysqlVariant

type MysqlVariant string

type Token

type Token struct {
	HeaderName string `yaml:"headerName"` // header名 Authorization
	HeaderType string `yaml:"headerType"` // 验证方式 Bearer
	CookieName string `yaml:"cookieName"`
	Key        string `yaml:"key"`
	Alg        string `yaml:"alg"`    //加密方式
	Typ        string `yaml:"type"`   //鉴权类型
	AuthTo     string `yaml:"authTo"` //鉴权所属 比如鉴权类型JWT,鉴权用户User JWT:User
	Expire     int64  `yaml:"expire"` //过期时间秒
}

type TokenMap added in v1.3.2

type TokenMap map[string]Token

type Web

type Web struct {
	Host   string      `yaml:"host"`
	Port   int32       `yaml:"port"`
	Mode   string      `yaml:"mode"`
	Prefix string      `yaml:"prefix"`
	Token  TokenMap    `yaml:"token"`
	Attach interface{} `yaml:"attach"` //附加配置 用户定义
}

func (*Web) Address

func (g *Web) Address() string

func (*Web) BindAttachType added in v1.3.2

func (c *Web) BindAttachType(dst any) (Web, error)

Jump to

Keyboard shortcuts

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