refactor: rename onLoaded

This commit is contained in:
Kevin Franklin Kim 2024-03-22 16:30:54 +01:00
parent ae481c5278
commit b4f8b95a4b
No known key found for this signature in database
4 changed files with 7 additions and 7 deletions

View File

@ -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

View File

@ -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

View File

@ -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")

View File

@ -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