Skip to content

Commit

Permalink
fix: fix race in http sync test
Browse files Browse the repository at this point in the history
Signed-off-by: Todd Baert <toddbaert@gmail.com>
  • Loading branch information
toddbaert committed Feb 10, 2023
1 parent e906757 commit 82c7b6a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/sync/http/http_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ func (hs *Sync) Sync(ctx context.Context, dataSync chan<- sync.DataSync) error {
return err
}

dataSync <- sync.DataSync{FlagData: fetch, Source: hs.URI, Type: sync.ALL}

_ = hs.Cron.AddFunc("*/5 * * * *", func() {
body, err := hs.fetchBodyFromURL(ctx, hs.URI)
if err != nil {
Expand Down Expand Up @@ -80,8 +78,10 @@ func (hs *Sync) Sync(ctx context.Context, dataSync chan<- sync.DataSync) error {
}
}
})

hs.Cron.Start()

dataSync <- sync.DataSync{FlagData: fetch, Source: hs.URI, Type: sync.ALL}

<-ctx.Done()
hs.Cron.Stop()

Expand Down

0 comments on commit 82c7b6a

Please sign in to comment.