mirror of
https://github.com/spf13/viper
synced 2025-05-11 06:37:27 +00:00
Merge c2b30602fd
into 0add84cdf2
This commit is contained in:
commit
e428a02acb
1 changed files with 6 additions and 3 deletions
9
viper.go
9
viper.go
|
@ -1860,8 +1860,8 @@ func (v *Viper) WatchRemoteConfig() error {
|
|||
return v.watchKeyValueConfig()
|
||||
}
|
||||
|
||||
func (v *Viper) WatchRemoteConfigOnChannel() error {
|
||||
return v.watchKeyValueConfigOnChannel()
|
||||
func (v *Viper) WatchRemoteConfigOnChannel(run func()) error {
|
||||
return v.watchKeyValueConfigOnChannel(run)
|
||||
}
|
||||
|
||||
// Retrieve the first found remote configuration.
|
||||
|
@ -1895,7 +1895,7 @@ func (v *Viper) getRemoteConfig(provider RemoteProvider) (map[string]interface{}
|
|||
}
|
||||
|
||||
// Retrieve the first found remote configuration.
|
||||
func (v *Viper) watchKeyValueConfigOnChannel() error {
|
||||
func (v *Viper) watchKeyValueConfigOnChannel(run func()) error {
|
||||
for _, rp := range v.remoteProviders {
|
||||
respc, _ := RemoteConfig.WatchChannel(rp)
|
||||
// Todo: Add quit channel
|
||||
|
@ -1904,6 +1904,9 @@ func (v *Viper) watchKeyValueConfigOnChannel() error {
|
|||
b := <-rc
|
||||
reader := bytes.NewReader(b.Value)
|
||||
v.unmarshalReader(reader, v.kvstore)
|
||||
if b.Error == nil {
|
||||
run()
|
||||
}
|
||||
}
|
||||
}(respc)
|
||||
return nil
|
||||
|
|
Loading…
Add table
Reference in a new issue