From b8c37e03f778b8c061a53c4c84f3b11a09b5d1ea Mon Sep 17 00:00:00 2001 From: ktong Date: Sat, 11 Nov 2023 18:09:45 -0800 Subject: [PATCH] typo --- provider.go | 4 ++-- provider/file/watch.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/provider.go b/provider.go index 32361321..23eafd69 100644 --- a/provider.go +++ b/provider.go @@ -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. diff --git a/provider/file/watch.go b/provider/file/watch.go index 45168c8f..541c7420 100644 --- a/provider/file/watch.go +++ b/provider/file/watch.go @@ -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) @@ -74,7 +74,7 @@ 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 { @@ -82,7 +82,7 @@ func (f File) Watch(ctx context.Context, watchFunc func(map[string]any)) error { continue } - watchFunc(values) + onChange(values) } case err, ok := <-watcher.Errors: