mirror of
https://github.com/foomo/contentserver.git
synced 2025-10-16 12:25:44 +00:00
refactor: mark loaded
This commit is contained in:
parent
5e7798a53f
commit
ae481c5278
@ -65,7 +65,15 @@ func (r *Repo) UpdateRoutine(ctx context.Context) error {
|
||||
l.Error("update failed", zap.Error(err))
|
||||
metrics.UpdatesFailedCounter.WithLabelValues().Inc()
|
||||
} else {
|
||||
l.Info("update success")
|
||||
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()
|
||||
}
|
||||
|
||||
|
||||
@ -26,16 +26,15 @@ const maxGetURIForNodeRecursionLevel = 1000
|
||||
// Repo content repository
|
||||
type (
|
||||
Repo struct {
|
||||
l *zap.Logger
|
||||
url string
|
||||
poll bool
|
||||
pollInterval time.Duration
|
||||
pollVersion string
|
||||
onStart func()
|
||||
loaded *atomic.Bool
|
||||
history *History
|
||||
httpClient *http.Client
|
||||
// updateLock sync.Mutex
|
||||
l *zap.Logger
|
||||
url string
|
||||
poll bool
|
||||
pollInterval time.Duration
|
||||
pollVersion string
|
||||
onStart func()
|
||||
loaded *atomic.Bool
|
||||
history *History
|
||||
httpClient *http.Client
|
||||
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()
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user