2021-04-19 10:09:43 +08:00
|
|
|
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
|
|
|
|
// with the License. You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
|
|
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
|
|
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
|
|
|
2021-06-22 14:40:07 +08:00
|
|
|
package grpcproxy
|
2021-01-28 20:51:44 +08:00
|
|
|
|
|
|
|
import (
|
2021-02-06 13:39:15 +08:00
|
|
|
"sync"
|
2021-01-28 20:51:44 +08:00
|
|
|
|
2021-04-22 14:45:57 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/util/funcutil"
|
|
|
|
"github.com/milvus-io/milvus/internal/util/paramtable"
|
2021-01-28 20:51:44 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type ParamTable struct {
|
|
|
|
paramtable.BaseTable
|
|
|
|
|
2021-01-29 09:27:26 +08:00
|
|
|
IndexServerAddress string
|
|
|
|
MasterAddress string
|
|
|
|
|
2021-06-21 18:22:13 +08:00
|
|
|
DataCoordAddress string
|
2021-01-29 09:27:26 +08:00
|
|
|
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() {
|
2021-02-23 18:08:17 +08:00
|
|
|
pt.initPort()
|
2021-01-29 09:27:26 +08:00
|
|
|
pt.initMasterAddress()
|
|
|
|
pt.initIndexServerAddress()
|
2021-06-21 18:22:13 +08:00
|
|
|
pt.initDataCoordAddress()
|
2021-01-29 09:27:26 +08:00
|
|
|
pt.initQueryServiceAddress()
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
2021-06-21 18:22:13 +08:00
|
|
|
func (pt *ParamTable) initDataCoordAddress() {
|
|
|
|
ret, err := pt.Load("_DataCoordAddress")
|
2021-01-29 09:27:26 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-06-21 18:22:13 +08:00
|
|
|
pt.DataCoordAddress = 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
|
|
|
|
}
|