Skip to content

Commit

Permalink
refactor: rename onLoaded
Browse files Browse the repository at this point in the history
  • Loading branch information
franklinkim committed Mar 22, 2024
1 parent ae481c5 commit b4f8b95
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/repo/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions pkg/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type (
poll bool
pollInterval time.Duration
pollVersion string
onStart func()
onLoaded func()
loaded *atomic.Bool
history *History
httpClient *http.Client
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b4f8b95

Please sign in to comment.