[skip ci] Fix golint error in proxy (#9283)

Signed-off-by: zhenshan.cao <zhenshan.cao@zilliz.com>
pull/9287/head
zhenshan.cao 2021-10-05 21:12:13 +08:00 committed by GitHub
parent 809129ba63
commit 6cf049130d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -23,6 +23,8 @@ import (
"github.com/milvus-io/milvus/internal/util/paramtable"
)
// ParamTable is a derived struct of paramtable.BaseTable. It achieves Composition by
// embedding paramtable.BaseTable. It is used to quickly and easily access the system configuration.
type ParamTable struct {
paramtable.BaseTable
@ -39,16 +41,19 @@ type ParamTable struct {
ServerMaxRecvSize int
}
// Params is a package scoped variable of type ParamTable.
var Params ParamTable
var once sync.Once
// Init is an override method of BaseTable's Init. It mainly calls the
// Init of BaseTable and do some other initialization.
func (pt *ParamTable) Init() {
once.Do(func() {
pt.BaseTable.Init()
pt.initParams()
pt.LoadFromEnv()
pt.LoadFromArgs()
pt.loadFromEnv()
pt.loadFromArgs()
pt.Address = pt.IP + ":" + strconv.FormatInt(int64(pt.Port), 10)
pt.initServerMaxSendSize()
@ -56,11 +61,11 @@ func (pt *ParamTable) Init() {
})
}
func (pt *ParamTable) LoadFromArgs() {
func (pt *ParamTable) loadFromArgs() {
}
func (pt *ParamTable) LoadFromEnv() {
func (pt *ParamTable) loadFromEnv() {
Params.IP = funcutil.GetLocalIP()
}

View File

@ -35,6 +35,6 @@ func TestParamTable(t *testing.T) {
Params.initServerMaxRecvSize()
assert.Equal(t, Params.ServerMaxRecvSize, grpcconfigs.DefaultServerMaxRecvSize)
Params.LoadFromEnv()
Params.loadFromEnv()
assert.Equal(t, Params.IP, funcutil.GetLocalIP())
}