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-06-22 19:08:03 +08:00
|
|
|
RootCoordAddress string
|
|
|
|
IndexCoordAddress string
|
2021-06-22 16:44:09 +08:00
|
|
|
DataCoordAddress string
|
|
|
|
QueryCoordAddress string
|
2021-01-29 09:27:26 +08:00
|
|
|
|
|
|
|
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-06-22 19:08:03 +08:00
|
|
|
pt.initRootCoordAddress()
|
|
|
|
pt.initIndexCoordAddress()
|
2021-06-21 18:22:13 +08:00
|
|
|
pt.initDataCoordAddress()
|
2021-06-22 16:44:09 +08:00
|
|
|
pt.initQueryCoordAddress()
|
2021-01-29 09:27:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// todo remove and use load from env
|
2021-06-22 19:08:03 +08:00
|
|
|
func (pt *ParamTable) initIndexCoordAddress() {
|
|
|
|
ret, err := pt.Load("_IndexCoordAddress")
|
2021-01-29 09:27:26 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-06-22 19:08:03 +08:00
|
|
|
pt.IndexCoordAddress = ret
|
2021-01-29 09:27:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// todo remove and use load from env
|
2021-06-22 19:08:03 +08:00
|
|
|
func (pt *ParamTable) initRootCoordAddress() {
|
|
|
|
ret, err := pt.Load("_RootCoordAddress")
|
2021-01-29 09:27:26 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-06-22 19:08:03 +08:00
|
|
|
pt.RootCoordAddress = 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
|
2021-06-22 16:44:09 +08:00
|
|
|
func (pt *ParamTable) initQueryCoordAddress() {
|
|
|
|
ret, err := pt.Load("_QueryCoordAddress")
|
2021-01-29 09:27:26 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-06-22 16:44:09 +08:00
|
|
|
pt.QueryCoordAddress = ret
|
2021-01-29 09:27:26 +08:00
|
|
|
}
|
2021-02-23 18:08:17 +08:00
|
|
|
|
|
|
|
func (pt *ParamTable) initPort() {
|
2021-06-22 19:08:03 +08:00
|
|
|
port := pt.ParseInt("proxy.port")
|
2021-02-23 18:08:17 +08:00
|
|
|
pt.Port = port
|
|
|
|
}
|