config

package
v0.0.0-...-115e584 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

用于从注册中心pull数据,和注册中心push数据到业务服务

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadGlobalConfig

func LoadGlobalConfig(configFile string) error

LoadGlobalConfig 从配置文件加载配置,并设置到全局结构里面

func RepairConfig

func RepairConfig(cfg *Config) error

RepairConfig 修复配置数据,填充默认值

func SetGlobalConfig

func SetGlobalConfig(cfg *Config)

SetGlobalConfig 设置全局配置

Types

type Broker

type Broker struct {
	MQ       string   `json:"mq"`
	Exchange string   `json:"exchange"`
	Args     []string `json:"args"`
}

type Config

type Config struct {
	Tracing  Tracing `json:"tracing"`
	DB       DB      `json:"db"`
	Redis    Redis   `json:"redis"`
	FilerDSN string  `json:"filer_dsn"`
	Broker   Broker  `json:"broker"`
	Server   Server  `json:"server"`
	Region   Region  `json:"region"`
}

func GlobalConfig

func GlobalConfig() *Config

GlobalConfig 获取全局配置对象

func LoadConfig

func LoadConfig(configFile string) (*Config, error)

LoadConfig 从配置文件加载配置

type DB

type DB struct {
	UserName string `json:"username"`
	Password string `json:"password"`
	Host     string `json:"host"`
	Debug    string `json:"debug"`
}

type FileProvider

type FileProvider struct {
	// contains filtered or unexported fields
}

FileProvider 从文件系统中拉取文件内容

func NewFileProvider

func NewFileProvider() *FileProvider

func (*FileProvider) Name

func (*FileProvider) Name() string

func (*FileProvider) Read

func (fp *FileProvider) Read(path string) ([]byte, error)

func (*FileProvider) Watch

func (fp *FileProvider) Watch(cb ProviderCallback)

type ProviderCallback

type ProviderCallback func(string, []byte)

type Redis

type Redis struct {
	Host         string `json:"host"`
	Password     string `json:"password"`
	SentinelHost string `json:"sentinel_host"`
	SentinelName string `json:"sentinel_name"`
}

type Region

type Region struct {
	Name string `json:"name"`
}

type Server

type Server struct {
	ServerName string `json:"server_name"`
}

type Tracing

type Tracing struct {
	ReportAddr string `json:"report_addr"`
	Level      string `json:"level"`
}

Config 配置

Jump to

Keyboard shortcuts

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