mirror of
https://github.com/foomo/contentserver.git
synced 2025-10-16 12:25:44 +00:00
refactor: rename onLoaded
This commit is contained in:
parent
ae481c5278
commit
b4f8b95a4b
@ -130,7 +130,7 @@ func initRepo(tb testing.TB, l *zap.Logger) *repo.Repo {
|
||||
),
|
||||
)
|
||||
up := make(chan bool, 1)
|
||||
r.OnStart(func() {
|
||||
r.OnLoaded(func() {
|
||||
up <- true
|
||||
})
|
||||
go r.Start(context.TODO()) //nolint:errcheck
|
||||
|
||||
@ -57,7 +57,7 @@ func NewSocketCommand() *cobra.Command {
|
||||
|
||||
// start repo
|
||||
up := make(chan bool, 1)
|
||||
r.OnStart(func() {
|
||||
r.OnLoaded(func() {
|
||||
up <- true
|
||||
})
|
||||
go r.Start(context.Background()) //nolint:errcheck
|
||||
|
||||
@ -68,8 +68,8 @@ func (r *Repo) UpdateRoutine(ctx context.Context) error {
|
||||
if !r.Loaded() {
|
||||
r.loaded.Store(true)
|
||||
l.Info("initial update success")
|
||||
if r.onStart != nil {
|
||||
r.onStart()
|
||||
if r.onLoaded != nil {
|
||||
r.onLoaded()
|
||||
}
|
||||
} else {
|
||||
l.Info("update success")
|
||||
|
||||
@ -31,7 +31,7 @@ type (
|
||||
poll bool
|
||||
pollInterval time.Duration
|
||||
pollVersion string
|
||||
onStart func()
|
||||
onLoaded func()
|
||||
loaded *atomic.Bool
|
||||
history *History
|
||||
httpClient *http.Client
|
||||
@ -130,8 +130,8 @@ func (r *Repo) SetJSONBuffer(v *bytes.Buffer) {
|
||||
// ~ Public methods
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
func (r *Repo) OnStart(fn func()) {
|
||||
r.onStart = fn
|
||||
func (r *Repo) OnLoaded(fn func()) {
|
||||
r.onLoaded = fn
|
||||
}
|
||||
|
||||
// GetURIs get many uris at once
|
||||
|
||||
Loading…
Reference in New Issue
Block a user