mirror of
https://github.com/spf13/viper
synced 2025-05-06 20:27:17 +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
|
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)
|
cm, err := getConfigManager(rp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
quit := make(chan bool)
|
quit := make(chan bool)
|
||||||
respChan := make(chan *viper.RemoteResponse, 0)
|
return cm.Watch(rp.Path(), quit) ,quit
|
||||||
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
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
viper.go
10
viper.go
|
@ -36,13 +36,9 @@ import (
|
||||||
"github.com/spf13/cast"
|
"github.com/spf13/cast"
|
||||||
jww "github.com/spf13/jwalterweatherman"
|
jww "github.com/spf13/jwalterweatherman"
|
||||||
"github.com/spf13/pflag"
|
"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
|
var v *Viper
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -52,7 +48,7 @@ func init() {
|
||||||
type remoteConfigFactory interface {
|
type remoteConfigFactory interface {
|
||||||
Get(rp RemoteProvider) (io.Reader, error)
|
Get(rp RemoteProvider) (io.Reader, error)
|
||||||
Watch(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
|
// RemoteConfig is optional, see the remote package
|
||||||
|
@ -1313,7 +1309,7 @@ func (v *Viper) watchKeyValueConfigOnChannel() error {
|
||||||
for _, rp := range v.remoteProviders {
|
for _, rp := range v.remoteProviders {
|
||||||
respc, _ := RemoteConfig.WatchChannel(rp)
|
respc, _ := RemoteConfig.WatchChannel(rp)
|
||||||
//Todo: Add quit channel
|
//Todo: Add quit channel
|
||||||
go func(rc <-chan *RemoteResponse) {
|
go func(rc <-chan *crypt.Response) {
|
||||||
for {
|
for {
|
||||||
b := <-rc
|
b := <-rc
|
||||||
reader := bytes.NewReader(b.Value)
|
reader := bytes.NewReader(b.Value)
|
||||||
|
|
Loading…
Add table
Reference in a new issue