Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseConfig ¶
func ParseConfig(cfgPath string)
ParseConfig 解析配置
当cfgPath不为空时,从文件解析配置,反之则从nacos读取
func ParseConfigFromFile ¶
func ParseConfigFromFile(cfgPath string)
func ParseConfigFromNacos ¶
func ParseConfigFromNacos()
ParseConfigFromNacos 从nacos读取并解析配置
注意:需要设置环境变量nacosAddrs 和 nacosNamespaceID
如:
nacosAddrs=192.168.224.3:8848,192.168.224.3:8848
nacosNamespaceID=f0c2f58d-54e3-45df-94cd-a6fb3a8fa534
func TestLoadTimeZonePanicWhileFailure ¶
func TestLoadTimeZonePanicWhileFailure()
TestLoadTimeZonePanicWhileFailure 测试加载时区
如果加载失败,将panic
Types ¶
type Config ¶
type Config struct { AppName string `yaml:"app_name" toml:"app_name" json:"app_name"` //应用名称 Timezone string `yaml:"timezone" toml:"timezone" json:"timezone"` //服务器时区 Debug bool `yaml:"debug" toml:"debug" json:"debug"` //是否是调试模式 Logger logger.Conf `yaml:"logger" toml:"logger" json:"logger"` //日志 Datasource db.Conf `yaml:"datasource" toml:"datasource" json:"datasource"` //数据库配置 Redis redis.Conf `yaml:"redis" toml:"redis" json:"redis"` //redis配置 RedisCluster redis.ClusterConf `yaml:"redis_cluster" toml:"redis_cluster" json:"redis_cluster"` //redis集群配置 Nats nats.Conf `yaml:"nats" toml:"nats" json:"nats"` //nats配置 JWT jwt.Conf `yaml:"jwt" toml:"jwt" json:"jwt"` //jwt配置 HttpServer HttpServerConf `yaml:"http_server" toml:"http_server" json:"http_server"` //http服务配置 }
Config 整体的配置信息
type HttpServerConf ¶
type HttpServerConf struct { Addr string `yaml:"addr" toml:"addr" json:"addr" default:":8080"` //监听地址 EnableSwagger bool `yaml:"enable_swagger" toml:"enable_swagger" json:"enable_swagger" default:"false"` //是否开启swagger文档 Prometheus PrometheusConf `yaml:"prometheus_conf" toml:"prometheus_conf" json:"prometheus_conf"` //prometheus配置 }
HttpServerConf http服务配置
type PrometheusConf ¶
Click to show internal directories.
Click to hide internal directories.