conf

package
v0.0.0-...-f4657ca Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfigFromEnv

func LoadConfigFromEnv() error

通过环境变量文件加载全局配置

func LoadConfigFromToml

func LoadConfigFromToml(filePath string) error

通过Toml文件加载全局配置

Types

type App

type App struct {
	Name string `toml:"name" env:"APP_NAME"`
	Http *Http  `toml:"http"`
	Grpc *Grpc  `toml:"grpc"`
}

App结构体

func NewDefaultApp

func NewDefaultApp() *App

App初始化函数

type Config

type Config struct {
	App     *App                         `toml:"app"`
	MongoDB *MongoDB                     `toml:"mongodb"`
	Mcenter *rpc.McenterGrpcClientConfig `toml:"mcenter"`
}

全局配置结构体

func C

func C() *Config

func NewDefaultConfig

func NewDefaultConfig() *Config

Config初始化函数

func (*Config) GetServiceIdByClientId

func (c *Config) GetServiceIdByClientId() (serviceId string, err error)

获取service id

func (*Config) WriteEndpointSetToMcenter

func (c *Config) WriteEndpointSetToMcenter(es *endpoint.EndpointSet) error

endpointSet通过grpc写入到mcenter

type Grpc

type Grpc struct {
	Host string `toml:"host" env:"GRPC_HOST"`
	Port int    `toml:"port" env:"GRPC_PORT"`
}

Grpc结构体

func NewDefaultGrpc

func NewDefaultGrpc() *Grpc

Grpc初始化函数

func (*Grpc) Addr

func (g *Grpc) Addr() string

type Http

type Http struct {
	Host string `toml:"host" env:"HTTP_HOST"`
	Port int    `toml:"port" env:"HTTP_PORT"`
}

Http结构体

func NewDefaultHttp

func NewDefaultHttp() *Http

Http初始化函数

func (*Http) Addr

func (h *Http) Addr() string

type MongoDB

type MongoDB struct {
	Username   string   `toml:"username" env:"MONGODB_USERNAME"`
	Password   string   `toml:"password" env:"MONGODB_PASSWORD"`
	Endpoints  []string `toml:"endpoints" env:"MONGODB_ENDPOINTS" envSeparator:","`
	Database   string   `toml:"database" env:"MONGODB_DATABASE"`
	AuthSource string   `toml:"authsource" env:"MONGODB_AUTHSOURCE"`
	// contains filtered or unexported fields
}

MongoDB结构体

func NewDefaultMongoDB

func NewDefaultMongoDB() *MongoDB

MongoDB初始化函数

func (*MongoDB) Client

func (m *MongoDB) Client() (*mongo.Client, error)

MongDB Client初始化

func (*MongoDB) GetClient

func (m *MongoDB) GetClient() (*mongo.Client, error)

获取MongDB Client

func (*MongoDB) GetDB

func (m *MongoDB) GetDB() (*mongo.Database, error)

MongoDB初始化数据库

Jump to

Keyboard shortcuts

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