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)
|
up := make(chan bool, 1)
|
||||||
r.OnStart(func() {
|
r.OnLoaded(func() {
|
||||||
up <- true
|
up <- true
|
||||||
})
|
})
|
||||||
go r.Start(context.TODO()) //nolint:errcheck
|
go r.Start(context.TODO()) //nolint:errcheck
|
||||||
|
|||||||
@ -57,7 +57,7 @@ func NewSocketCommand() *cobra.Command {
|
|||||||
|
|
||||||
// start repo
|
// start repo
|
||||||
up := make(chan bool, 1)
|
up := make(chan bool, 1)
|
||||||
r.OnStart(func() {
|
r.OnLoaded(func() {
|
||||||
up <- true
|
up <- true
|
||||||
})
|
})
|
||||||
go r.Start(context.Background()) //nolint:errcheck
|
go r.Start(context.Background()) //nolint:errcheck
|
||||||
|
|||||||
@ -68,8 +68,8 @@ func (r *Repo) UpdateRoutine(ctx context.Context) error {
|
|||||||
if !r.Loaded() {
|
if !r.Loaded() {
|
||||||
r.loaded.Store(true)
|
r.loaded.Store(true)
|
||||||
l.Info("initial update success")
|
l.Info("initial update success")
|
||||||
if r.onStart != nil {
|
if r.onLoaded != nil {
|
||||||
r.onStart()
|
r.onLoaded()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
l.Info("update success")
|
l.Info("update success")
|
||||||
|
|||||||
@ -31,7 +31,7 @@ type (
|
|||||||
poll bool
|
poll bool
|
||||||
pollInterval time.Duration
|
pollInterval time.Duration
|
||||||
pollVersion string
|
pollVersion string
|
||||||
onStart func()
|
onLoaded func()
|
||||||
loaded *atomic.Bool
|
loaded *atomic.Bool
|
||||||
history *History
|
history *History
|
||||||
httpClient *http.Client
|
httpClient *http.Client
|
||||||
@ -130,8 +130,8 @@ func (r *Repo) SetJSONBuffer(v *bytes.Buffer) {
|
|||||||
// ~ Public methods
|
// ~ Public methods
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
func (r *Repo) OnStart(fn func()) {
|
func (r *Repo) OnLoaded(fn func()) {
|
||||||
r.onStart = fn
|
r.onLoaded = fn
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetURIs get many uris at once
|
// GetURIs get many uris at once
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user