Skip to content

Commit

Permalink
Don't block on consumers start
Browse files Browse the repository at this point in the history
  • Loading branch information
anodar committed May 24, 2024
1 parent 3c08b79 commit 71ce50f
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions validator/valnode/redis/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,20 @@ func (s *ValidationServer) Start(ctx_in context.Context) {
})
})
}

for {
select {
case <-readyStreams:
log.Trace("At least one stream is ready")
return // Don't block Start if at least one of the stream is ready.
case <-time.After(s.streamTimeout):
log.Error("Waiting for redis streams timed out")
case <-ctx_in.Done():
log.Info(("Context expired, failed to start"))
return
s.StopWaiter.LaunchThread(func(ctx context.Context) {
for {
select {
case <-readyStreams:
log.Trace("At least one stream is ready")
return // Don't block Start if at least one of the stream is ready.
case <-time.After(s.streamTimeout):
log.Error("Waiting for redis streams timed out")
case <-ctx.Done():
log.Info(("Context expired, failed to start"))
return
}
}
}
})
}

type ValidationServerConfig struct {
Expand Down

0 comments on commit 71ce50f

Please sign in to comment.