3 Star 11 Fork 3

os-lee/easy-paas

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
config.go 1.70 KB
一键复制 编辑 原始数据 按行查看 历史
lee 提交于 2024-10-01 09:38 +08:00 . 使用GRPC协议,采集节点信息
package config
import (
"github.com/spf13/viper"
"os"
)
var Conf *Config
func Init() {
workDir, _ := os.Getwd()
viper.SetConfigName("config")
viper.SetConfigType("yaml")
viper.AddConfigPath(workDir + "/agent/config")
err := viper.ReadInConfig()
if err != nil {
panic(err)
}
err = viper.Unmarshal(&Conf)
if err != nil {
panic(err)
}
}
type Config struct {
Server *Server `yaml:"server"`
Etcd *Etcd `yaml:"etcd"`
Kafka *Kafka `yaml:"kafka"`
Es *Es `yaml:"es"`
MySQL *MySQL `yaml:"mysql"`
Node *Node `yaml:"node"`
}
type Server struct {
Producer string `yaml:"producer"`
Consumer string `yaml:"consumer"`
Host string `yaml:"host"`
Version string `yaml:"version"`
}
type Etcd struct {
Endpoints []string `yaml:"endpoints"`
Ttl int64 `yaml:"ttl"`
}
type Kafka struct {
Brokers []string `yaml:"brokers"`
Topic string `yaml:"topic"`
RetryNum int `yaml:"retryNum"`
}
type Es struct {
Address []string `yaml:"address"`
MaxChanSize int `yaml:"maxChanSize"`
GoNum int `yaml:"goNum"`
Index Index `yaml:"index"`
Username string `yaml:"username"`
Password string `yaml:"password"`
}
type Index struct {
Name string `yaml:"name"`
CutByApp bool `yaml:"cutByApp"`
CutByMonth bool `yaml:"cutByMonth"`
}
type MySQL struct {
DriverName string `yaml:"driver"`
Host string `yaml:"host"`
Port string `yaml:"port"`
Database string `yaml:"database"`
UserName string `yaml:"username"`
Password string `yaml:"password"`
Charset string `yaml:"charset"`
}
type Node struct {
ServerAddr string `yaml:"serverAddr"`
ServerName string `yaml:"serverName"`
ClientName string `yaml:"clientName"`
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/os-lee/easy-paas.git
git@gitee.com:os-lee/easy-paas.git
os-lee
easy-paas
easy-paas
6cf1638f64c0

搜索帮助