refactor: mark loaded

This commit is contained in:
Kevin Franklin Kim 2024-03-22 16:26:34 +01:00
parent 5e7798a53f
commit ae481c5278
No known key found for this signature in database
2 changed files with 18 additions and 18 deletions

View File

@ -64,8 +64,16 @@ func (r *Repo) UpdateRoutine(ctx context.Context) error {
if err != nil {
l.Error("update failed", zap.Error(err))
metrics.UpdatesFailedCounter.WithLabelValues().Inc()
} else {
if !r.Loaded() {
r.loaded.Store(true)
l.Info("initial update success")
if r.onStart != nil {
r.onStart()
}
} else {
l.Info("update success")
}
metrics.UpdatesCompletedCounter.WithLabelValues().Inc()
}

View File

@ -35,7 +35,6 @@ type (
loaded *atomic.Bool
history *History
httpClient *http.Client
// updateLock sync.Mutex
dimensionUpdateChannel chan *RepoDimension
dimensionUpdateDoneChannel chan error
updateInProgressChannel chan chan updateResponse
@ -316,7 +315,6 @@ func (r *Repo) Start(ctx context.Context) error {
l.Warn("could not restore previous repo content", zap.Error(err))
} else {
l.Info("restored previous repo")
r.loaded.Store(true)
}
if r.poll {
@ -336,15 +334,9 @@ func (r *Repo) Start(ctx context.Context) error {
zap.Float64("own_runtime", resp.Stats.OwnRuntime),
zap.Float64("repo_runtime", resp.Stats.RepoRuntime),
)
} else {
r.loaded.Store(true)
}
}
if r.onStart != nil {
r.onStart()
}
return g.Wait()
}