diff --git a/internal/application/fetcher.go b/internal/application/fetcher.go index 36cef5b..2f8efcd 100644 --- a/internal/application/fetcher.go +++ b/internal/application/fetcher.go @@ -19,6 +19,10 @@ func (a *Application) fetch() { return } + a.fetchIsRunningMutex.Lock() + a.fetchIsRunning = true + a.fetchIsRunningMutex.Unlock() + log.Println("Fetching data for", a.name) req, err := http.NewRequestWithContext(a.ctx, "GET", a.config.Endpoint, nil) @@ -52,10 +56,6 @@ func (a *Application) fetch() { a.storage.Put(data) - a.fetchIsRunningMutex.Lock() - a.fetchIsRunning = true - a.fetchIsRunningMutex.Unlock() - a.fetchIsRunningMutex.Lock() a.fetchIsRunning = false a.fetchIsRunningMutex.Unlock()