From 3ff99d4fd117f464ad2b58d693826eca9d0fb1ca Mon Sep 17 00:00:00 2001 From: Yuzuki616 Date: Sat, 26 Oct 2024 04:11:03 +0900 Subject: [PATCH] fix watcher --- conf/watcher.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/conf/watcher.go b/conf/watcher.go index 8f2ffbf..8bb770e 100644 --- a/conf/watcher.go +++ b/conf/watcher.go @@ -4,6 +4,7 @@ import ( "Ratte/common/watcher" "errors" "fmt" + log "github.com/sirupsen/logrus" "path" ) @@ -31,9 +32,14 @@ func (c *Conf) SetErrorHandler(w ErrorHandler) { } func (c *Conf) Watch() error { - if c.watcherHandle != nil { + if c.watcherHandle == nil { return errors.New("no watch handler") } + if c.errorHandler == nil { + c.errorHandler = func(err error) { + log.WithField("service", "conf_watcher").Error(err) + } + } if IsHttpUrl(c.path) { if c.Watcher.WatchRemoteConfig { w := watcher.NewHTTPWatcher(c.path, c.Watcher.RemoteInterval)