2022-09-23 09:50:52 +08:00
|
|
|
package paramtable
|
|
|
|
|
2023-02-13 16:50:33 +08:00
|
|
|
import (
|
2023-10-20 14:26:09 +08:00
|
|
|
"go.uber.org/zap"
|
|
|
|
|
2023-08-16 16:03:33 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/config"
|
2023-10-20 14:26:09 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/log"
|
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-08-31 10:25:01 +08:00
|
|
|
SoPath ParamItem `refreshable:"false"`
|
|
|
|
SoConfig ParamGroup `refreshable:"true"`
|
2022-09-23 09:50:52 +08:00
|
|
|
}
|
|
|
|
|
2023-09-05 10:31:48 +08:00
|
|
|
func (h *hookConfig) init(base *BaseTable) {
|
|
|
|
h.hookBase = base
|
2023-10-20 14:26:09 +08:00
|
|
|
log.Info("hook config", zap.Any("hook", base.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-09-05 10:31:48 +08:00
|
|
|
h.SoPath.Init(base.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-09-05 10:31:48 +08:00
|
|
|
h.SoConfig.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))
|
|
|
|
}
|