diff --git a/remote/remote.go b/remote/remote.go index 94838a7..f100a9c 100644 --- a/remote/remote.go +++ b/remote/remote.go @@ -40,24 +40,24 @@ func (rc remoteConfigProvider) Watch(rp viper.RemoteProvider) (io.Reader, error) return bytes.NewReader(resp), nil } -func (rc remoteConfigProvider) WatchChannel(rp viper.RemoteProvider) (<-chan *viper.Response, chan bool) { +func (rc remoteConfigProvider) WatchChannel(rp viper.RemoteProvider) (<-chan *viper.RemoteResponse, chan bool) { cm, err := getConfigManager(rp) if err != nil { return nil, nil } quit := make(chan bool) quitwc := make(chan bool) - viperResponsCh := make(chan *viper.Response) + viperResponsCh := make(chan *viper.RemoteResponse) cryptoResponseCh := cm.Watch(rp.Path(), quit) // need this function to convert the Channel response form crypt.Response to viper.Response - go func(cr <-chan *crypt.Response,vr chan<- *viper.Response, quitwc <-chan bool, quit chan<- bool) { + go func(cr <-chan *crypt.Response,vr chan<- *viper.RemoteResponse, quitwc <-chan bool, quit chan<- bool) { for { select { case <- quitwc: quit <- true return case resp := <-cr: - vr <- &viper.Response{ + vr <- &viper.RemoteResponse{ Error: resp.Error, Value: resp.Value, } diff --git a/viper.go b/viper.go index c18e463..22a2ed8 100644 --- a/viper.go +++ b/viper.go @@ -40,7 +40,7 @@ import ( var v *Viper -type Response struct { +type RemoteResponse struct { Value []byte Error error } @@ -52,7 +52,7 @@ func init() { type remoteConfigFactory interface { Get(rp RemoteProvider) (io.Reader, error) Watch(rp RemoteProvider) (io.Reader, error) - WatchChannel(rp RemoteProvider)(<-chan *Response, chan bool) + WatchChannel(rp RemoteProvider)(<-chan *RemoteResponse, chan bool) } // RemoteConfig is optional, see the remote package @@ -1313,7 +1313,7 @@ func (v *Viper) watchKeyValueConfigOnChannel() error { for _, rp := range v.remoteProviders { respc, _ := RemoteConfig.WatchChannel(rp) //Todo: Add quit channel - go func(rc <-chan *Response) { + go func(rc <-chan *RemoteResponse) { for { b := <-rc reader := bytes.NewReader(b.Value)