2021-01-28 20:51:44 +08:00
|
|
|
package grpcproxynode
|
|
|
|
|
|
|
|
import (
|
2021-02-06 13:39:15 +08:00
|
|
|
"sync"
|
2021-01-28 20:51:44 +08:00
|
|
|
|
2021-02-23 11:40:30 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/util/funcutil"
|
2021-01-28 20:51:44 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/util/paramtable"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ParamTable struct {
|
|
|
|
paramtable.BaseTable
|
|
|
|
|
|
|
|
ProxyServiceAddress string
|
2021-01-29 09:27:26 +08:00
|
|
|
ProxyServicePort int
|
|
|
|
|
|
|
|
IndexServerAddress string
|
|
|
|
MasterAddress string
|
|
|
|
|
|
|
|
DataServiceAddress string
|
|
|
|
QueryServiceAddress string
|
|
|
|
|
|
|
|
IP string
|
|
|
|
Port int
|
|
|
|
Address string
|
2021-01-28 20:51:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
var Params ParamTable
|
2021-02-06 13:39:15 +08:00
|
|
|
var once sync.Once
|
2021-01-28 20:51:44 +08:00
|
|
|
|
|
|
|
func (pt *ParamTable) Init() {
|
2021-02-06 13:39:15 +08:00
|
|
|
once.Do(func() {
|
|
|
|
pt.BaseTable.Init()
|
|
|
|
pt.initParams()
|
|
|
|
})
|
2021-01-29 09:27:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (pt *ParamTable) LoadFromArgs() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (pt *ParamTable) LoadFromEnv() {
|
2021-02-23 11:40:30 +08:00
|
|
|
Params.IP = funcutil.GetLocalIP()
|
2021-01-29 09:27:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (pt *ParamTable) initParams() {
|
|
|
|
pt.initPoxyServicePort()
|
2021-02-23 18:08:17 +08:00
|
|
|
pt.initPort()
|
2021-01-28 20:51:44 +08:00
|
|
|
pt.initProxyServiceAddress()
|
2021-01-29 09:27:26 +08:00
|
|
|
pt.initMasterAddress()
|
|
|
|
pt.initIndexServerAddress()
|
|
|
|
pt.initDataServiceAddress()
|
|
|
|
pt.initQueryServiceAddress()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (pt *ParamTable) initPoxyServicePort() {
|
|
|
|
pt.ProxyServicePort = pt.ParseInt("proxyService.port")
|
2021-01-28 20:51:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (pt *ParamTable) initProxyServiceAddress() {
|
2021-03-22 16:36:10 +08:00
|
|
|
ret, err := pt.Load("_PROXY_SERVICE_ADDRESS")
|
2021-01-28 20:51:44 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-03-22 16:36:10 +08:00
|
|
|
pt.ProxyServiceAddress = ret
|
2021-01-28 20:51:44 +08:00
|
|
|
}
|
2021-01-29 09:27:26 +08:00
|
|
|
|
|
|
|
// todo remove and use load from env
|
|
|
|
func (pt *ParamTable) initIndexServerAddress() {
|
2021-03-22 16:36:10 +08:00
|
|
|
ret, err := pt.Load("IndexServiceAddress")
|
2021-01-29 09:27:26 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-03-22 16:36:10 +08:00
|
|
|
pt.IndexServerAddress = ret
|
2021-01-29 09:27:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// todo remove and use load from env
|
|
|
|
func (pt *ParamTable) initMasterAddress() {
|
2021-03-22 16:36:10 +08:00
|
|
|
ret, err := pt.Load("_MasterAddress")
|
2021-01-29 09:27:26 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-03-22 16:36:10 +08:00
|
|
|
pt.MasterAddress = ret
|
2021-01-29 09:27:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// todo remove and use load from env
|
|
|
|
func (pt *ParamTable) initDataServiceAddress() {
|
2021-03-22 16:36:10 +08:00
|
|
|
ret, err := pt.Load("_DataServiceAddress")
|
2021-01-29 09:27:26 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-03-22 16:36:10 +08:00
|
|
|
pt.DataServiceAddress = ret
|
2021-01-29 09:27:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// todo remove and use load from env
|
|
|
|
func (pt *ParamTable) initQueryServiceAddress() {
|
2021-03-22 16:36:10 +08:00
|
|
|
ret, err := pt.Load("_QueryServiceAddress")
|
2021-01-29 09:27:26 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-03-22 16:36:10 +08:00
|
|
|
pt.QueryServiceAddress = ret
|
2021-01-29 09:27:26 +08:00
|
|
|
}
|
2021-02-23 18:08:17 +08:00
|
|
|
|
|
|
|
func (pt *ParamTable) initPort() {
|
|
|
|
port := pt.ParseInt("proxyNode.port")
|
|
|
|
pt.Port = port
|
|
|
|
}
|