Skip to content

Commit 061e9fc

Browse files
committed
feat: Add special handling for redis.Nil errors in fetchTask method
1 parent ab58982 commit 061e9fc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

redis.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package redisdb
33
import (
44
"context"
55
"encoding/json"
6+
"errors"
7+
"fmt"
68
"strings"
79
"sync"
810
"sync/atomic"
@@ -110,7 +112,14 @@ func (w *Worker) fetchTask() {
110112
Block: w.opts.blockTime,
111113
}).Result()
112114
if err != nil {
113-
w.opts.logger.Errorf("error while reading from redis %v", err)
115+
workerInfo := fmt.Sprintf("{streamName: %q, group: %q, consumer: %q}",
116+
w.opts.streamName, w.opts.group, w.opts.consumer)
117+
if errors.Is(err, redis.Nil) {
118+
w.opts.logger.Infof("no data while reading from redis stream %s", workerInfo)
119+
} else {
120+
w.opts.logger.Errorf("error while reading from redis %s %v", workerInfo, err)
121+
}
122+
114123
continue
115124
}
116125
// we have received the data we should loop it and queue the messages

0 commit comments

Comments
 (0)