feature: add registry watcherStatus endpoint (#913) (#915)

Co-authored-by: Kent Dong <ch3cho@qq.com>
This commit is contained in:
韩贤涛
2024-04-24 10:39:41 +08:00
committed by GitHub
parent e68b5c86c4
commit a787088c0e
6 changed files with 78 additions and 4 deletions

View File

@@ -49,6 +49,7 @@ type Watcher interface {
Run()
Stop()
IsHealthy() bool
IsReady() bool
GetRegistryType() string
AppendServiceUpdateHandler(f func())
ReadyHandler(f func(bool))
@@ -57,17 +58,22 @@ type Watcher interface {
type BaseWatcher struct {
UpdateService ServiceUpdateHandler
Ready ReadyHandler
ReadyStatus bool
}
func (w *BaseWatcher) Run() {}
func (w *BaseWatcher) Stop() {}
func (w *BaseWatcher) IsHealthy() bool { return true }
func (w *BaseWatcher) IsReady() bool { return w.ReadyStatus }
func (w *BaseWatcher) GetRegistryType() string { return "" }
func (w *BaseWatcher) AppendServiceUpdateHandler(f func()) {
w.UpdateService = f
}
func (w *BaseWatcher) ReadyHandler(f func(bool)) {
w.Ready = f
func (w *BaseWatcher) ReadyHandler(f func(isReady bool)) {
w.Ready = func(isReady bool) {
w.ReadyStatus = isReady
f(isReady)
}
}
type ServiceUpdateHandler func()