milvus/internal/distributed/datanode/param_table.go
cai.zhang 1d899513dd Unify service name in config file
Signed-off-by: cai.zhang <cai.zhang@zilliz.com>
2021-02-24 18:46:19 +08:00

60 lines
1010 B
Go

package grpcdatanode
import (
"sync"
"github.com/zilliztech/milvus-distributed/internal/util/funcutil"
"github.com/zilliztech/milvus-distributed/internal/util/paramtable"
)
var Params ParamTable
var once sync.Once
type ParamTable struct {
paramtable.BaseTable
IP string
Port int
MasterAddress string
DataServiceAddress string
}
func (pt *ParamTable) Init() {
once.Do(func() {
pt.BaseTable.Init()
pt.initMasterAddress()
pt.initDataServiceAddress()
pt.initPort()
})
}
func (pt *ParamTable) LoadFromArgs() {
}
func (pt *ParamTable) LoadFromEnv() {
Params.IP = funcutil.GetLocalIP()
}
func (pt *ParamTable) initPort() {
port := pt.ParseInt("dataNode.port")
pt.Port = port
}
func (pt *ParamTable) initMasterAddress() {
ret, err := pt.Load("_MasterAddress")
if err != nil {
panic(err)
}
pt.MasterAddress = ret
}
func (pt *ParamTable) initDataServiceAddress() {
ret, err := pt.Load("_DataServiceAddress")
if err != nil {
panic(err)
}
pt.DataServiceAddress = ret
}