Skip to content

Commit

Permalink
Remove obsolete Watch() stubs. Closes #171.
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Sep 19, 2022
1 parent 0e9e5e9 commit 3e03354
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 41 deletions.
11 changes: 5 additions & 6 deletions README.md
Expand Up @@ -73,13 +73,12 @@ func main() {
```

### Watching files for changes
The `koanf.Provider` interface has a `Watch(cb)` method that asks a provider
to watch for changes and trigger the given callback that can live reload the
configuration. This is not goroutine safe if there are concurrent `*Get()`
calls happening on the koanf object while it is doing a `Load()`. Such
scenarios will need mutex locking.
Some providers expose a `Watch()` method that makes the provider watch for changes
in configuration and trigger a callback to reload the configuration.
This is not goroutine safe if there are concurrent `*Get()` calls happening on the
koanf object while it is doing a `Load()`. Such scenarios will need mutex locking.

Currently, `file.Provider` supports this.
`file, appconfig, vault, consul` providers have a `Watch()` method.


```go
Expand Down
5 changes: 0 additions & 5 deletions providers/basicflag/basicflag.go
Expand Up @@ -62,8 +62,3 @@ func (p *Pflag) Read() (map[string]interface{}, error) {
func (p *Pflag) ReadBytes() ([]byte, error) {
return nil, errors.New("basicflag provider does not support this method")
}

// Watch is not supported.
func (p *Pflag) Watch(cb func(event interface{}, err error)) error {
return errors.New("basicflag provider does not support this method")
}
5 changes: 0 additions & 5 deletions providers/confmap/confmap.go
Expand Up @@ -35,8 +35,3 @@ func (e *Confmap) ReadBytes() ([]byte, error) {
func (e *Confmap) Read() (map[string]interface{}, error) {
return e.mp, nil
}

// Watch is not supported.
func (e *Confmap) Watch(cb func(event interface{}, err error)) error {
return errors.New("confmap provider does not support this method")
}
5 changes: 0 additions & 5 deletions providers/env/env.go
Expand Up @@ -96,8 +96,3 @@ func (e *Env) Read() (map[string]interface{}, error) {

return maps.Unflatten(mp, e.delim), nil
}

// Watch is not supported.
func (e *Env) Watch(cb func(event interface{}, err error)) error {
return errors.New("env provider does not support this method")
}
6 changes: 1 addition & 5 deletions providers/fs/fs.go
Expand Up @@ -2,6 +2,7 @@
// from given fs.FS to be used with a koanf.Parser to parse
// into conf maps.

//go:build go1.16
// +build go1.16

package fs
Expand Down Expand Up @@ -38,8 +39,3 @@ func (f *FS) ReadBytes() ([]byte, error) {
func (f *FS) Read() (map[string]interface{}, error) {
return nil, errors.New("fs.FS provider does not support this method")
}

// Watch is not supported by the fs.FS provider.
func (f *FS) Watch(cb func(event interface{}, err error)) error {
return errors.New("fs.FS provider does not support this method")
}
5 changes: 0 additions & 5 deletions providers/rawbytes/rawbytes.go
Expand Up @@ -29,8 +29,3 @@ func (r *RawBytes) ReadBytes() ([]byte, error) {
func (r *RawBytes) Read() (map[string]interface{}, error) {
return nil, errors.New("buf provider does not support this method")
}

// Watch is not supported.
func (r *RawBytes) Watch(cb func(event interface{}, err error)) error {
return errors.New("rawbytes provider does not support this method")
}
5 changes: 0 additions & 5 deletions providers/s3/s3.go
Expand Up @@ -68,8 +68,3 @@ func (r *S3) ReadBytes() ([]byte, error) {
func (r *S3) Read() (map[string]interface{}, error) {
return nil, errors.New("s3 provider does not support this method")
}

// Watch is not supported.
func (r *S3) Watch(cb func(event interface{}, err error)) error {
return errors.New("s3 provider does not support this method")
}
5 changes: 0 additions & 5 deletions providers/structs/structs.go
Expand Up @@ -46,8 +46,3 @@ func (s *Structs) Read() (map[string]interface{}, error) {

return out, nil
}

// Watch is not supported by the structs provider.
func (s *Structs) Watch(cb func(event interface{}, err error)) error {
return errors.New("structs provider does not support this method")
}

0 comments on commit 3e03354

Please sign in to comment.