Skip to content

Commit 225c0bf

Browse files
committed
fix(tests): add global ctx in tests
1 parent 7a0f316 commit 225c0bf

File tree

2 files changed

+6
-32
lines changed

2 files changed

+6
-32
lines changed

internal_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import (
1616
. "github.com/bsm/gomega"
1717
)
1818

19+
var ctx = context.TODO()
20+
1921
var _ = Describe("newClusterState", func() {
2022
var state *clusterState
2123

push/processor.go

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package push
22

33
import (
44
"context"
5-
"time"
65

76
"github.com/redis/go-redis/v9/internal"
87
"github.com/redis/go-redis/v9/internal/proto"
@@ -52,23 +51,8 @@ func (p *Processor) ProcessPendingNotifications(ctx context.Context, handlerCtx
5251
if rd == nil {
5352
return nil
5453
}
55-
conn := handlerCtx.Conn
56-
if conn == nil {
57-
return nil
58-
}
59-
netConn := handlerCtx.Conn.GetNetConn()
60-
if netConn == nil {
61-
return nil
62-
}
6354

6455
for {
65-
// Set a short read deadline to check for available data
66-
// otherwise we may block on Peek if there is no data available
67-
err := netConn.SetReadDeadline(time.Now().Add(1))
68-
if err != nil {
69-
return err
70-
}
71-
7256
// Check if there's data available to read
7357
replyType, err := rd.PeekReplyType()
7458
if err != nil {
@@ -120,7 +104,7 @@ func (p *Processor) ProcessPendingNotifications(ctx context.Context, handlerCtx
120104
}
121105
}
122106

123-
return netConn.SetReadDeadline(time.Time{})
107+
return nil
124108
}
125109

126110
// VoidProcessor discards all push notifications without processing them
@@ -154,20 +138,8 @@ func (v *VoidProcessor) ProcessPendingNotifications(_ context.Context, handlerCt
154138
if rd == nil {
155139
return nil
156140
}
157-
conn := handlerCtx.Conn
158-
if conn == nil {
159-
return nil
160-
}
161-
netConn := handlerCtx.Conn.GetNetConn()
162-
if netConn == nil {
163-
return nil
164-
}
141+
165142
for {
166-
// Set a short read deadline to check for available data
167-
err := netConn.SetReadDeadline(time.Now().Add(1))
168-
if err != nil {
169-
return err
170-
}
171143
// Check if there's data available to read
172144
replyType, err := rd.PeekReplyType()
173145
if err != nil {
@@ -196,15 +168,15 @@ func (v *VoidProcessor) ProcessPendingNotifications(_ context.Context, handlerCt
196168
return nil
197169
}
198170
}
199-
return netConn.SetReadDeadline(time.Time{})
171+
return nil
200172
}
201173

202174
// willHandleNotificationInClient checks if a notification type should be ignored by the push notification
203175
// processor and handled by other specialized systems instead (pub/sub, streams, keyspace, etc.).
204176
func willHandleNotificationInClient(notificationType string) bool {
205177
switch notificationType {
206178
// Pub/Sub notifications - handled by pub/sub system
207-
case "message", // Regular pub/sub message
179+
case "message", // Regular pub/sub message
208180
"pmessage", // Pattern pub/sub message
209181
"subscribe", // Subscription confirmation
210182
"unsubscribe", // Unsubscription confirmation

0 commit comments

Comments
 (0)