Skip to content

Commit

Permalink
Use time.After instead of ticker
Browse files Browse the repository at this point in the history
  • Loading branch information
nikola-jokic committed Dec 20, 2024
1 parent cc94a21 commit cb2679c
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions server/handler/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ type ConfigFetcher struct {
func (cf *ConfigFetcher) ConfigForRepositoryBranch(ctx context.Context, client *github.Client, owner, repository, branch string) FetchedConfig {
retries := 0
delay := 1 * time.Second
ticker := time.NewTicker(delay)
defer ticker.Stop()
for {
c, err := cf.Loader.LoadConfig(ctx, client, owner, repository, branch)
fc := FetchedConfig{
Expand All @@ -62,12 +60,11 @@ func (cf *ConfigFetcher) ConfigForRepositoryBranch(ctx context.Context, client *
return fc
}

ticker.Reset(delay)
select {
case <-ctx.Done():
fc.LoadError = ctx.Err()
return fc
case <-ticker.C:
case <-time.After(delay):
delay *= 2
continue
}
Expand Down

0 comments on commit cb2679c

Please sign in to comment.