fix watcher

This commit is contained in:
Yuzuki616
2024-10-26 04:11:03 +09:00
parent 5143401ca5
commit 3ff99d4fd1

View File

@@ -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)