conf

package
v0.0.0-...-c01aa29 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TextFormat 文本格式
	TextFormat = LogFormat("text")
	// JSONFormat json格式
	JSONFormat = LogFormat("json")
)
View Source
const (
	// ToFile 保存到文件
	ToFile = LogTo("file")
	// ToStdout 打印到标准输出
	ToStdout = LogTo("stdout")
)

Variables

This section is empty.

Functions

func LoadConfigFromEnv

func LoadConfigFromEnv() error

LoadConfigFromEnv 从环境变量中加载配置

func LoadConfigFromToml

func LoadConfigFromToml(filePath string) error

LoadConfigFromToml 从toml中添加配置文件, 并初始化全局对象

Types

type Config

type Config struct {
	App     *app         `toml:"app"`
	HTTP    *http        `toml:"http"`
	GRPC    *grpc        `toml:"grpc"`
	Log     *log         `toml:"log"`
	Mongo   *mongodb     `toml:"mongodb"`
	Keyauth *keyauth     `toml:"keyauth"`
	Cache   *_cache      `toml:"cache"`
	Etcd    *Etcd        `toml:"etcd"`
	Nats    *nats.Config `toml:"nats"`
	Bus     *bus         `toml:"bus"`
}

Config 应用配置

func C

func C() *Config

C 全局配置对象

type Etcd

type Etcd struct {
	Endpoints   []string `toml:"endpoints" env:"ETCD_ENDPOINTS" envSeparator:","`
	UserName    string   `toml:"username" env:"ETCD_USERNAME"`
	Password    string   `toml:"password" env:"ETCD_PASSWORD"`
	Prefix      string   `toml:"prefix" env:"ETCD_Prefix"`
	InstanceTTL int64    `toml:"instance_ttl" env:"ETCD_INSTANCE_TTL"`
}

func (*Etcd) GetClient

func (e *Etcd) GetClient() *clientv3.Client

func (*Etcd) Validate

func (e *Etcd) Validate() error

type LogFormat

type LogFormat string

LogFormat 日志格式

type LogTo

type LogTo string

LogTo 日志记录到哪儿

Jump to

Keyboard shortcuts

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