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))
|
l.Error("update failed", zap.Error(err))
|
||||||
metrics.UpdatesFailedCounter.WithLabelValues().Inc()
|
metrics.UpdatesFailedCounter.WithLabelValues().Inc()
|
||||||
} else {
|
} 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()
|
metrics.UpdatesCompletedCounter.WithLabelValues().Inc()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,16 +26,15 @@ const maxGetURIForNodeRecursionLevel = 1000
|
|||||||
// Repo content repository
|
// Repo content repository
|
||||||
type (
|
type (
|
||||||
Repo struct {
|
Repo struct {
|
||||||
l *zap.Logger
|
l *zap.Logger
|
||||||
url string
|
url string
|
||||||
poll bool
|
poll bool
|
||||||
pollInterval time.Duration
|
pollInterval time.Duration
|
||||||
pollVersion string
|
pollVersion string
|
||||||
onStart func()
|
onStart func()
|
||||||
loaded *atomic.Bool
|
loaded *atomic.Bool
|
||||||
history *History
|
history *History
|
||||||
httpClient *http.Client
|
httpClient *http.Client
|
||||||
// updateLock sync.Mutex
|
|
||||||
dimensionUpdateChannel chan *RepoDimension
|
dimensionUpdateChannel chan *RepoDimension
|
||||||
dimensionUpdateDoneChannel chan error
|
dimensionUpdateDoneChannel chan error
|
||||||
updateInProgressChannel chan chan updateResponse
|
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))
|
l.Warn("could not restore previous repo content", zap.Error(err))
|
||||||
} else {
|
} else {
|
||||||
l.Info("restored previous repo")
|
l.Info("restored previous repo")
|
||||||
r.loaded.Store(true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.poll {
|
if r.poll {
|
||||||
@ -336,15 +334,9 @@ func (r *Repo) Start(ctx context.Context) error {
|
|||||||
zap.Float64("own_runtime", resp.Stats.OwnRuntime),
|
zap.Float64("own_runtime", resp.Stats.OwnRuntime),
|
||||||
zap.Float64("repo_runtime", resp.Stats.RepoRuntime),
|
zap.Float64("repo_runtime", resp.Stats.RepoRuntime),
|
||||||
)
|
)
|
||||||
} else {
|
|
||||||
r.loaded.Store(true)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.onStart != nil {
|
|
||||||
r.onStart()
|
|
||||||
}
|
|
||||||
|
|
||||||
return g.Wait()
|
return g.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user