Skip to content

Commit 25bde87

Browse files
committed
add comments
1 parent 5d1d063 commit 25bde87

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

push/processor.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ type NotificationProcessor interface {
1212
// GetHandler returns the handler for a specific push notification name.
1313
GetHandler(pushNotificationName string) NotificationHandler
1414
// ProcessPendingNotifications checks for and processes any pending push notifications.
15+
// To be used when it is known that there are notifications on the socket.
16+
// It will try to read from the socket and if it is empty - it may block.
1517
ProcessPendingNotifications(ctx context.Context, handlerCtx NotificationHandlerContext, rd *proto.Reader) error
1618
// RegisterHandler registers a handler for a specific push notification name.
1719
RegisterHandler(pushNotificationName string, handler NotificationHandler, protected bool) error
@@ -47,6 +49,8 @@ func (p *Processor) UnregisterHandler(pushNotificationName string) error {
4749
}
4850

4951
// ProcessPendingNotifications checks for and processes any pending push notifications
52+
// This method should be called by the client in WithReader before reading the reply
53+
// It will try to read from the socket and if it is empty - it may block.
5054
func (p *Processor) ProcessPendingNotifications(ctx context.Context, handlerCtx NotificationHandlerContext, rd *proto.Reader) error {
5155
if rd == nil {
5256
return nil
@@ -134,6 +138,11 @@ func (v *VoidProcessor) UnregisterHandler(pushNotificationName string) error {
134138
// ProcessPendingNotifications for VoidProcessor does nothing since push notifications
135139
// are only available in RESP3 and this processor is used for RESP2 connections.
136140
// This avoids unnecessary buffer scanning overhead.
141+
// It does however read and discard all push notifications from the buffer to avoid
142+
// them being interpreted as a reply.
143+
// This method should be called by the client in WithReader before reading the reply
144+
// to be sure there are no buffered push notifications.
145+
// It will try to read from the socket and if it is empty - it may block.
137146
func (v *VoidProcessor) ProcessPendingNotifications(_ context.Context, handlerCtx NotificationHandlerContext, rd *proto.Reader) error {
138147
// read and discard all push notifications
139148
if rd == nil {

0 commit comments

Comments
 (0)