可以直接在节点启动时自动注册节点

This commit is contained in:
GoEdgeLab
2020-10-17 11:14:40 +08:00
parent 8ea2cc9a64
commit f1ffe8c438
7 changed files with 130 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ import (
"io/ioutil"
)
// 节点API配置
type APIConfig struct {
RPC struct {
Endpoints []string `yaml:"endpoints"`
@@ -28,3 +29,13 @@ func LoadAPIConfig() (*APIConfig, error) {
return config, nil
}
// 保存到文件
func (this *APIConfig) WriteFile(path string) error {
data, err := yaml.Marshal(this)
if err != nil {
return err
}
err = ioutil.WriteFile(path, data, 0666)
return err
}

View File

@@ -0,0 +1,10 @@
package configs
// 集群配置
type ClusterConfig struct {
RPC struct {
Endpoints []string `yaml:"endpoints"`
} `yaml:"rpc"`
ClusterId string `yaml:"clusterId"`
Secret string `yaml:"secret"`
}