2022-09-23 09:50:52 +08:00
|
|
|
package paramtable
|
|
|
|
|
2023-02-13 16:50:33 +08:00
|
|
|
import (
|
2023-08-16 16:03:33 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/config"
|
2023-04-06 19:14:32 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/log"
|
2023-08-16 16:03:33 +08:00
|
|
|
"go.uber.org/zap"
|
2023-02-13 16:50:33 +08:00
|
|
|
)
|
|
|
|
|
2022-09-23 09:50:52 +08:00
|
|
|
const hookYamlFile = "hook.yaml"
|
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
type hookConfig struct {
|
2023-08-16 16:03:33 +08:00
|
|
|
hookBase *BaseTable
|
|
|
|
|
2023-07-03 15:18:24 +08:00
|
|
|
SoPath ParamItem `refreshable:"false"`
|
2023-08-16 16:03:33 +08:00
|
|
|
SoConfig ParamGroup `refreshable:"true"`
|
2023-07-03 15:18:24 +08:00
|
|
|
QueryNodePluginConfig ParamItem `refreshable:"true"`
|
|
|
|
QueryNodePluginTuningConfig ParamGroup `refreshable:"true"`
|
2022-09-23 09:50:52 +08:00
|
|
|
}
|
|
|
|
|
2023-03-24 15:21:59 +08:00
|
|
|
func (h *hookConfig) init(base *BaseTable) {
|
|
|
|
hookBase := &BaseTable{YamlFiles: []string{hookYamlFile}}
|
2023-08-16 16:03:33 +08:00
|
|
|
hookBase.init(2)
|
|
|
|
h.hookBase = hookBase
|
2023-03-24 15:21:59 +08:00
|
|
|
|
|
|
|
log.Info("hook config", zap.Any("hook", hookBase.FileConfigs()))
|
2022-09-23 09:50:52 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
h.SoPath = ParamItem{
|
|
|
|
Key: "soPath",
|
|
|
|
Version: "2.0.0",
|
|
|
|
DefaultValue: "",
|
|
|
|
}
|
2023-03-24 15:21:59 +08:00
|
|
|
h.SoPath.Init(hookBase.mgr)
|
2022-09-23 09:50:52 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
h.SoConfig = ParamGroup{
|
|
|
|
KeyPrefix: "",
|
|
|
|
Version: "2.2.0",
|
|
|
|
}
|
2023-03-24 15:21:59 +08:00
|
|
|
h.SoConfig.Init(hookBase.mgr)
|
|
|
|
|
|
|
|
h.QueryNodePluginConfig = ParamItem{
|
|
|
|
Key: "autoindex.params.search",
|
|
|
|
Version: "2.3.0",
|
|
|
|
}
|
|
|
|
h.QueryNodePluginConfig.Init(base.mgr)
|
2023-07-03 15:18:24 +08:00
|
|
|
|
|
|
|
h.QueryNodePluginTuningConfig = ParamGroup{
|
|
|
|
KeyPrefix: "autoindex.params.tuning.",
|
|
|
|
Version: "2.3.0",
|
|
|
|
}
|
|
|
|
h.QueryNodePluginTuningConfig.Init(base.mgr)
|
2022-09-23 09:50:52 +08:00
|
|
|
}
|
2023-08-16 16:03:33 +08:00
|
|
|
|
|
|
|
func (h *hookConfig) WatchHookWithPrefix(ident string, keyPrefix string, onEvent func(*config.Event)) {
|
|
|
|
h.hookBase.mgr.Dispatcher.RegisterForKeyPrefix(keyPrefix, config.NewHandler(ident, onEvent))
|
|
|
|
}
|