mirror of
https://github.com/spf13/viper
synced 2025-05-06 20:27:17 +00:00
Lint remote.go
This commit is contained in:
parent
760350d83c
commit
c588a0c383
1 changed files with 9 additions and 9 deletions
|
@ -8,10 +8,11 @@ package remote
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/spf13/viper"
|
||||
crypt "github.com/xordataexchange/crypt/config"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
crypt "github.com/xordataexchange/crypt/config"
|
||||
)
|
||||
|
||||
type remoteConfigProvider struct{}
|
||||
|
@ -33,7 +34,7 @@ func (rc remoteConfigProvider) Watch(rp viper.RemoteProvider) (io.Reader, error)
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp,err := cm.Get(rp.Path())
|
||||
resp, err := cm.Get(rp.Path())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -47,13 +48,13 @@ func (rc remoteConfigProvider) WatchChannel(rp viper.RemoteProvider) (<-chan *vi
|
|||
}
|
||||
quit := make(chan bool)
|
||||
quitwc := make(chan bool)
|
||||
viperResponsCh := make(chan *viper.RemoteResponse)
|
||||
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.RemoteResponse, 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:
|
||||
case <-quitwc:
|
||||
quit <- true
|
||||
return
|
||||
case resp := <-cr:
|
||||
|
@ -65,13 +66,12 @@ func (rc remoteConfigProvider) WatchChannel(rp viper.RemoteProvider) (<-chan *vi
|
|||
}
|
||||
|
||||
}
|
||||
}(cryptoResponseCh,viperResponsCh,quitwc,quit)
|
||||
}(cryptoResponseCh, viperResponsCh, quitwc, quit)
|
||||
|
||||
return viperResponsCh,quitwc
|
||||
return viperResponsCh, quitwc
|
||||
|
||||
}
|
||||
|
||||
|
||||
func getConfigManager(rp viper.RemoteProvider) (crypt.ConfigManager, error) {
|
||||
|
||||
var cm crypt.ConfigManager
|
||||
|
|
Loading…
Add table
Reference in a new issue