conf

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: Artistic-2.0 Imports: 9 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"`
	Log *log `toml:"log"`

	Mongo *mongodb `toml:"mongodb"`

	// 注册中心的配置, 期望通过该配置能访问到注册中心
	// 通过 mcenter 通过的SDK(GRPC SDK Client) 来访问
	// 如何初始化 Mcenter GRPC Client ?
	// 通过 SDK 提供的LoadClientFromConfig来初始化的
	// 初始化后 通过mcenter 客户端包里面的全局变量 C来进行访问
	// 就是rpc.C().Instance()
	// 后面 实现实例注册, 就执行使用 rpc.C() 这个全局对象
	Mcenter *rpc.Config `toml:"mcenter"`
}

Config 应用配置

func C

func C() *Config

C 全局配置对象

func (*Config) InitGlobal

func (c *Config) InitGlobal() error

之前是在LoadConfigFromEnv做的配置,现在在Config对象这里加一个方法

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