Skip to content

Commit

Permalink
use ticker to allow for timely posting of bids to s3
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshvanahalli committed Dec 16, 2024
1 parent 0d23279 commit e1798b4
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion timeboost/s3_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,27 @@ func NewS3StorageService(config *S3StorageServiceConfig, sqlDB *SqliteDatabase)

func (s *S3StorageService) Start(ctx context.Context) {
s.StopWaiter.Start(ctx, s)
s.CallIteratively(s.uploadBatches)
if err := s.LaunchThreadSafe(func(ctx context.Context) {
ticker := time.NewTicker(s.config.UploadInterval)
defer ticker.Stop()
for {
interval := s.uploadBatches(ctx)
if ctx.Err() != nil {
return
}
if interval != s.config.UploadInterval { // Indicates error case, so we'll retry sooner than upload-interval
time.Sleep(interval)
continue
}
select {
case <-ctx.Done():
return
case <-ticker.C:
}
}
}); err != nil {
log.Error("Failed to launch s3-storage service of auctioneer", "err", err)
}
}

func (s *S3StorageService) uploadBatch(ctx context.Context, batch []byte, fistRound uint64) error {
Expand Down

0 comments on commit e1798b4

Please sign in to comment.