MCPcopy
hub / github.com/spf13/viper / watchKeyValueConfigOnChannel

Method watchKeyValueConfigOnChannel

remote.go:210–231  ·  view source on GitHub ↗

Retrieve the first found remote configuration.

()

Source from the content-addressed store, hash-verified

208
209// Retrieve the first found remote configuration.
210func (v *Viper) watchKeyValueConfigOnChannel() error {
211 if len(v.remoteProviders) == 0 {
212 return RemoteConfigError("No Remote Providers")
213 }
214
215 for _, rp := range v.remoteProviders {
216 respc, _ := RemoteConfig.WatchChannel(rp)
217 // Todo: Add quit channel
218 go func(rc <-chan *RemoteResponse) {
219 for {
220 b := <-rc
221 reader := bytes.NewReader(b.Value)
222 err := v.unmarshalReader(reader, v.kvstore)
223 if err != nil {
224 v.logger.Error(fmt.Errorf("failed to unmarshal remote config: %w", err).Error())
225 }
226 }
227 }(respc)
228 return nil
229 }
230 return RemoteConfigError("No Files Found")
231}
232
233// Retrieve the first found remote configuration.
234func (v *Viper) watchKeyValueConfig() error {

Callers 1

Calls 4

unmarshalReaderMethod · 0.95
RemoteConfigErrorTypeAlias · 0.85
WatchChannelMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected