[Pubsub] handle closed redis channel (#800)

This commit is contained in:
Johannes Batzill 2023-11-15 00:04:34 +00:00 committed by Harness
parent 07951e7d7e
commit 0793af5f9f

View File

@ -142,7 +142,11 @@ func (s *redisSubscriber) start(ctx context.Context) {
select { select {
case <-ctx.Done(): case <-ctx.Done():
return return
case msg := <-ch: case msg, ok := <-ch:
if !ok {
log.Ctx(ctx).Debug().Msg("redis channel was closed")
return
}
if err := s.handler([]byte(msg.Payload)); err != nil { if err := s.handler([]byte(msg.Payload)); err != nil {
log.Ctx(ctx).Err(err).Msg("received an error from handler function") log.Ctx(ctx).Err(err).Msg("received an error from handler function")
} }