diff --git a/go/config.go b/go/config.go index 4e6d97c..8d36fb1 100644 --- a/go/config.go +++ b/go/config.go @@ -335,16 +335,23 @@ func emitConfigChanges(callbacks []func(string, any), attached *core.Core, chang fn(change.Key, change.Value) } if attached != nil { - _ = attached.ACTION(ConfigChanged{ + reportConfigBroadcast(attached.ACTION(ConfigChanged{ Key: change.Key, Value: change.Value, Previous: change.Previous, Source: source, - }) + }), source) } } } +func reportConfigBroadcast(r core.Result, source string) { + if r.OK { + return + } + core.Warn("config change broadcast failed", "source", source, "err", r.Error()) +} + // Get retrieves a configuration value by dot-notation key and stores it in out. // If key is empty, it unmarshals the entire configuration into out. // The out parameter must be a pointer to the target type. @@ -405,7 +412,7 @@ func (c *Config) Set(key string, v any) core.Result { fn(key, v) } if attached != nil { - _ = attached.ACTION(ConfigChanged{Key: key, Value: v, Previous: previous, Source: configChangeSourceSet}) + reportConfigBroadcast(attached.ACTION(ConfigChanged{Key: key, Value: v, Previous: previous, Source: configChangeSourceSet}), configChangeSourceSet) } persistToStore(store, key, v) return core.Ok(nil) @@ -428,7 +435,7 @@ func (c *Config) Commit() core.Result { return core.Fail(core.E("config.Commit", "failed to save config", resultCause(r).(error))) } if attached != nil { - _ = attached.ACTION(ConfigChanged{Key: "", Value: nil, Source: configChangeSourceCommit}) + reportConfigBroadcast(attached.ACTION(ConfigChanged{Key: "", Value: nil, Source: configChangeSourceCommit}), configChangeSourceCommit) } return core.Ok(nil) } diff --git a/go/go.mod b/go/go.mod index 4a146c4..1629eb2 100644 --- a/go/go.mod +++ b/go/go.mod @@ -22,7 +22,6 @@ require ( require ( dappco.re/go/io v0.9.0 - dappco.re/go/log v0.9.0 github.com/go-viper/mapstructure/v2 v2.5.0 // indirect github.com/pelletier/go-toml/v2 v2.2.4 // indirect github.com/sagikazarmark/locafero v0.12.0 // indirect diff --git a/go/go.sum b/go/go.sum index c9bb439..c1b418b 100644 --- a/go/go.sum +++ b/go/go.sum @@ -2,8 +2,6 @@ dappco.re/go v0.9.0 h1:4ruZRNqKDDva8o6g65tYggjGVe42E6/lMZfVKXtr3p0= dappco.re/go v0.9.0/go.mod h1:xapr7fLK4/9Pu2iSCr4qZuIuatmtx1j56zS/oPDbGyQ= dappco.re/go/io v0.9.0 h1:TyHUuUJdZ73CXQlBpqx47SNyFFzgwA5OPSKu4Twb2f0= dappco.re/go/io v0.9.0/go.mod h1:K5jWSLMdk0X9HqJ6b1I+8tKqcNpNWgpcUZi/fGm28Q8= -dappco.re/go/log v0.9.0 h1:9+OiBUDyUNvqZZ++XemcjJPCgypr+Yf/1e5OP3X2nrk= -dappco.re/go/log v0.9.0/go.mod h1:IC04Em9SfVTcXiWc1BqZDQfa1MtOuMDEermZkQcTz9c= forge.lthn.ai/Snider/Borg v0.3.1 h1:gfC1ZTpLoZai07oOWJiVeQ8+qJYK8A795tgVGJHbVL8= forge.lthn.ai/Snider/Borg v0.3.1/go.mod h1:Z7DJD0yHXsxSyM7Mjl6/g4gH1NBsIz44Bf5AFlV76Wg= forge.lthn.ai/Snider/Enchantrix v0.0.4 h1:biwpix/bdedfyc0iVeK15awhhJKH6TEMYOTXzHXx5TI= diff --git a/go/watch.go b/go/watch.go index cf1754d..2e3a446 100644 --- a/go/watch.go +++ b/go/watch.go @@ -117,7 +117,9 @@ func (c *Config) StopWatch() { if !fw.stopped { fw.stopped = true close(fw.stop) - _ = fw.w.Close() + if r := fw.w.Close(); !r.OK { + core.Warn("config watcher close failed", "err", r.Error()) + } } fw.mu.Unlock() } @@ -149,7 +151,9 @@ func (c *Config) watchLoop(fw *fileWatcher) { // Best-effort for atomic-save editors: the replacement file may // not exist during the swap. There is no automatic retry loop; // another fsnotify event is required to attempt Add again. - _ = fw.w.Add(path) + if r := fw.w.Add(path); !r.OK { + core.Warn("config watcher re-add failed", "file", path, "err", r.Error()) + } } requestReload(reloadRequests) case _, ok := <-fw.w.Errors(): @@ -229,12 +233,12 @@ func (c *Config) reloadAndNotify() { fn(change.Key, change.Value) } if attached != nil { - _ = attached.ACTION(ConfigChanged{ + reportConfigBroadcast(attached.ACTION(ConfigChanged{ Key: change.Key, Value: change.Value, Previous: change.Previous, Source: configChangeSourceFile, - }) + }), configChangeSourceFile) } } }