config

package
v0.0.0-...-2baa201 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// 全局请求超时
	Timeout int64
	// RequestTimeout int64
	// ReadTimeout    int64
	// WriteTimeout   int64
	Database *DatabseConfig `json:"mysql,omitempty" mapstructure:"database"`
	Redis    *RedisConfig   `json:"redis,omitempty"`
	Logger   *LoggerConfig  `json:"logger,omitempty"`
	Otel     *OtelConfig    `json:"otel,omitempty"`
}

func InitGlobalConfig

func InitGlobalConfig(conf *Config) (*Config, error)

func (*Config) GetDatabase

func (c *Config) GetDatabase() *DatabseConfig

获取数据库配置 如果没有配置,则从环境变量读取 如果环境变量没有配置,则使用默认配置

func (*Config) GetLoggerConfig

func (c *Config) GetLoggerConfig() *LoggerConfig

获取 logger 配置 如果没有配置,则从环境变量读取 如果环境变量没有配置,则使用默认配置

func (*Config) GetOtelConfig

func (c *Config) GetOtelConfig() *OtelConfig

获取 otel 配置 如果没有配置,则从环境变量读取 如果环境变量没有配置,则使用默认配置

func (*Config) GetRedis

func (c *Config) GetRedis() *RedisConfig

获取 redis 配置 如果没有配置,则从环境变量读取 如果环境变量没有配置,则使用默认配置

type DatabseConfig

type DatabseConfig struct {
	Dsn               string `json:"dsn,omitempty"`
	Driver            string `json:"driver,omitempty"`
	Loc               string `json:"loc,omitempty"`
	ParseTime         string `json:"parse_time,omitempty"`
	Timeout           int64  `json:"timeout,omitempty"`
	MaxOpen           int    `json:"max_open,omitempty"`
	MaxIdle           int    `json:"max_idle,omitempty"`
	ConnMaxLifeSecond int    `json:"conn_max_life_second,omitempty"`
}

type LoggerConfig

type LoggerConfig struct {
	Formatter logrus.Formatter
	RootPath  string
	// OutputPath   string
	ReportCaller bool
	Level        uint32
}

type OtelConfig

type OtelConfig struct {
	Exporter sdktrace.SpanExporter
}

type RedisConfig

type RedisConfig struct {
	Addr     string
	Password string
	DB       int
	PoolSize int
	MaxIdle  int
}

Jump to

Keyboard shortcuts

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