Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions go/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down
1 change: 0 additions & 1 deletion go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
12 changes: 8 additions & 4 deletions go/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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)
}
}
}
Expand Down
Loading