mirror of
https://github.com/spf13/viper
synced 2025-05-06 12:17:18 +00:00
removed not needed struct
This commit is contained in:
parent
5f2abee1c5
commit
b912d8b835
2 changed files with 5 additions and 22 deletions
|
@ -40,26 +40,13 @@ func (rc remoteConfigProvider) Watch(rp viper.RemoteProvider) (io.Reader, error)
|
|||
|
||||
return bytes.NewReader(resp), nil
|
||||
}
|
||||
func (rc remoteConfigProvider) WatchChannel(rp viper.RemoteProvider) (<-chan *viper.RemoteResponse, chan bool) {
|
||||
func (rc remoteConfigProvider) WatchChannel(rp viper.RemoteProvider) (<-chan *crypt.Response, chan bool) {
|
||||
cm, err := getConfigManager(rp)
|
||||
if err != nil {
|
||||
return nil, nil
|
||||
}
|
||||
quit := make(chan bool)
|
||||
respChan := make(chan *viper.RemoteResponse, 0)
|
||||
watchchan := cm.Watch(rp.Path(), quit)
|
||||
// Todo Add quit channel
|
||||
go func(w <-chan *crypt.Response) {
|
||||
for {
|
||||
resp := <-w
|
||||
respChan <- &viper.RemoteResponse{
|
||||
Error: resp.Error,
|
||||
Value: resp.Value,
|
||||
}
|
||||
}
|
||||
|
||||
}(watchchan)
|
||||
return respChan ,quit
|
||||
return cm.Watch(rp.Path(), quit) ,quit
|
||||
|
||||
}
|
||||
|
||||
|
|
10
viper.go
10
viper.go
|
@ -36,13 +36,9 @@ import (
|
|||
"github.com/spf13/cast"
|
||||
jww "github.com/spf13/jwalterweatherman"
|
||||
"github.com/spf13/pflag"
|
||||
crypt "github.com/xordataexchange/crypt/config"
|
||||
)
|
||||
|
||||
// Response represents a response from a backend store.
|
||||
type RemoteResponse struct {
|
||||
Value []byte
|
||||
Error error
|
||||
}
|
||||
var v *Viper
|
||||
|
||||
func init() {
|
||||
|
@ -52,7 +48,7 @@ func init() {
|
|||
type remoteConfigFactory interface {
|
||||
Get(rp RemoteProvider) (io.Reader, error)
|
||||
Watch(rp RemoteProvider) (io.Reader, error)
|
||||
WatchChannel(rp RemoteProvider)(<-chan *RemoteResponse, chan bool)
|
||||
WatchChannel(rp RemoteProvider)(<-chan *crypt.Response, chan bool)
|
||||
}
|
||||
|
||||
// RemoteConfig is optional, see the remote package
|
||||
|
@ -1313,7 +1309,7 @@ func (v *Viper) watchKeyValueConfigOnChannel() error {
|
|||
for _, rp := range v.remoteProviders {
|
||||
respc, _ := RemoteConfig.WatchChannel(rp)
|
||||
//Todo: Add quit channel
|
||||
go func(rc <-chan *RemoteResponse) {
|
||||
go func(rc <-chan *crypt.Response) {
|
||||
for {
|
||||
b := <-rc
|
||||
reader := bytes.NewReader(b.Value)
|
||||
|
|
Loading…
Add table
Reference in a new issue