mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-07 01:28:27 +08:00
65 lines
1.1 KiB
Go
65 lines
1.1 KiB
Go
package grpcdatanode
|
|
|
|
import (
|
|
"os"
|
|
"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() // todo random generate
|
|
})
|
|
}
|
|
|
|
func (pt *ParamTable) LoadFromArgs() {
|
|
|
|
}
|
|
|
|
func (pt *ParamTable) LoadFromEnv() {
|
|
Params.IP = funcutil.GetLocalIP()
|
|
host := os.Getenv("DATA_NODE_HOST")
|
|
if len(host) > 0 {
|
|
Params.IP = host
|
|
}
|
|
}
|
|
|
|
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
|
|
}
|