未验证 提交 19f21097 编写于 作者: S SimFG 提交者: GitHub

Support to update the hook config in the runtime (#26350)

Signed-off-by: NSimFG <bang.fu@zilliz.com>
上级 bafcbf5a
......@@ -7,14 +7,13 @@ import (
"strconv"
"strings"
"github.com/milvus-io/milvus/pkg/util/paramtable"
"go.uber.org/zap"
"google.golang.org/grpc"
"github.com/milvus-io/milvus-proto/go-api/v2/hook"
"github.com/milvus-io/milvus/pkg/config"
"github.com/milvus-io/milvus/pkg/log"
"github.com/milvus-io/milvus/pkg/metrics"
"github.com/milvus-io/milvus/pkg/util/paramtable"
"go.uber.org/zap"
"google.golang.org/grpc"
)
type defaultHook struct {
......@@ -67,6 +66,16 @@ func initHook() error {
if err = hoo.Init(Params.HookCfg.SoConfig.GetValue()); err != nil {
return fmt.Errorf("fail to init configs for the hook, error: %s", err.Error())
}
Params.HookCfg.WatchHookWithPrefix("watch_hook", "", func(event *config.Event) {
log.Info("receive the hook refresh event", zap.Any("event", event))
go func() {
soConfig := Params.HookCfg.SoConfig.GetValue()
log.Info("refresh hook configs", zap.Any("config", soConfig))
if err = hoo.Init(soConfig); err != nil {
log.Panic("fail to init configs for the hook when refreshing", zap.Error(err))
}
}()
})
return nil
}
......
package paramtable
import (
"go.uber.org/zap"
"github.com/milvus-io/milvus/pkg/config"
"github.com/milvus-io/milvus/pkg/log"
"go.uber.org/zap"
)
const hookYamlFile = "hook.yaml"
type hookConfig struct {
hookBase *BaseTable
SoPath ParamItem `refreshable:"false"`
SoConfig ParamGroup `refreshable:"false"`
SoConfig ParamGroup `refreshable:"true"`
QueryNodePluginConfig ParamItem `refreshable:"true"`
QueryNodePluginTuningConfig ParamGroup `refreshable:"true"`
}
func (h *hookConfig) init(base *BaseTable) {
hookBase := &BaseTable{YamlFiles: []string{hookYamlFile}}
hookBase.init(0)
hookBase.init(2)
h.hookBase = hookBase
log.Info("hook config", zap.Any("hook", hookBase.FileConfigs()))
......@@ -46,3 +49,7 @@ func (h *hookConfig) init(base *BaseTable) {
}
h.QueryNodePluginTuningConfig.Init(base.mgr)
}
func (h *hookConfig) WatchHookWithPrefix(ident string, keyPrefix string, onEvent func(*config.Event)) {
h.hookBase.mgr.Dispatcher.RegisterForKeyPrefix(keyPrefix, config.NewHandler(ident, onEvent))
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册