Skip to content

Commit

Permalink
typo
Browse files Browse the repository at this point in the history
  • Loading branch information
ktong committed Nov 12, 2023
1 parent c67e064 commit b8c37e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ type Loader interface {

// Watcher is the interface that wraps the Watch method.
//
// Watch watches configuration and triggers onchange callback with latest
// Watch watches configuration and triggers onChange callback with latest
// full configurations as a nested map[string]any when it changes.
// It blocks until ctx is done, or the watching returns an error.
type Watcher interface {
Watch(ctx context.Context, onchange func(map[string]any)) error
Watch(ctx context.Context, onChange func(map[string]any)) error
}

// ConfigAware is the interface that wraps the WithConfig method.
Expand Down
6 changes: 3 additions & 3 deletions provider/file/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
// It blocks until ctx is done, or the service returns a non-retryable error.
//
//nolint:cyclop,funlen
func (f File) Watch(ctx context.Context, watchFunc func(map[string]any)) error {
func (f File) Watch(ctx context.Context, onChange func(map[string]any)) error {
watcher, err := fsnotify.NewWatcher()
if err != nil {
return fmt.Errorf("create file watcher for %s: %w", f.path, err)
Expand Down Expand Up @@ -74,15 +74,15 @@ func (f File) Watch(ctx context.Context, watchFunc func(map[string]any)) error {
switch {
case event.Has(fsnotify.Remove):
slog.Warn("Config file has been removed.", "file", f.path)
watchFunc(nil)
onChange(nil)
case event.Has(fsnotify.Create) || event.Has(fsnotify.Write):
values, err := f.Load()
if err != nil {
slog.Error("Error when reloading config file", "file", f.path, "error", err)

continue
}
watchFunc(values)
onChange(values)
}

case err, ok := <-watcher.Errors:
Expand Down

0 comments on commit b8c37e0

Please sign in to comment.