Fix golint error in proxy (#9905)

Signed-off-by: zhenshan.cao <zhenshan.cao@zilliz.com>
This commit is contained in:
zhenshan.cao 2021-10-15 20:27:09 +08:00 committed by GitHub
parent 56466508cc
commit f6a836c784
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,9 +22,12 @@ import (
)
const (
SuggestPulsarMaxMessageSizeKey = 5 * 1024 * 1024
// SuggestPulsarMaxMessageSize defines the maximum size of Pulsar message.
SuggestPulsarMaxMessageSize = 5 * 1024 * 1024
)
// 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
@ -70,15 +73,19 @@ type ParamTable struct {
UpdatedTime time.Time
}
// Params is a package scoped variable of type ParamTable.
var Params ParamTable
var once sync.Once
// InitOnce ensures that Init is only called once.
func (pt *ParamTable) InitOnce() {
once.Do(func() {
pt.Init()
})
}
// 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() {
pt.BaseTable.Init()
err := pt.LoadYaml("advanced/proxy.yaml")
@ -111,6 +118,7 @@ func (pt *ParamTable) Init() {
pt.initRoleName()
}
// InitAlias initialize Alias member.
func (pt *ParamTable) InitAlias(alias string) {
pt.Alias = alias
}
@ -263,11 +271,11 @@ func (pt *ParamTable) initPulsarMaxMessageSize() {
maxMessageSizeStr, err := pt.Load("pulsar.maxMessageSize")
if err != nil {
pt.PulsarMaxMessageSize = SuggestPulsarMaxMessageSizeKey
pt.PulsarMaxMessageSize = SuggestPulsarMaxMessageSize
} else {
maxMessageSize, err := strconv.Atoi(maxMessageSizeStr)
if err != nil {
pt.PulsarMaxMessageSize = SuggestPulsarMaxMessageSizeKey
pt.PulsarMaxMessageSize = SuggestPulsarMaxMessageSize
} else {
pt.PulsarMaxMessageSize = maxMessageSize
}