Skip to content

Commit 9ae4519

Browse files
authored
fix: improve Redis error handling and logging in fetchTask (#36)
- Add handling for Redis 'no message' errors in fetchTask - Log a specific info message when no messages are available, then continue retrying fix #31 Signed-off-by: appleboy <appleboy.tw@gmail.com>
1 parent 0cdac33 commit 9ae4519

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

redis.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package redisdb
33
import (
44
"context"
55
"encoding/json"
6+
"errors"
67
"strings"
78
"sync"
89
"sync/atomic"
@@ -110,6 +111,10 @@ func (w *Worker) fetchTask() {
110111
Block: w.opts.blockTime,
111112
}).Result()
112113
if err != nil {
114+
if errors.Is(err, redis.Nil) {
115+
w.opts.logger.Infof("no messages available in Redis stream [%s]", w.opts.streamName)
116+
continue
117+
}
113118
w.opts.logger.Errorf("error while reading from redis %v", err)
114119
continue
115120
}

0 commit comments

Comments
 (0)