@@ -19,11 +19,13 @@ type NotificationHandler struct {
1919// HandlePushNotification processes push notifications with hook support.
2020func (snh * NotificationHandler ) HandlePushNotification (ctx context.Context , handlerCtx push.NotificationHandlerContext , notification []interface {}) error {
2121 if len (notification ) == 0 {
22+ internal .Logger .Printf (ctx , "hitless: invalid notification format: %v" , notification )
2223 return ErrInvalidNotification
2324 }
2425
2526 notificationType , ok := notification [0 ].(string )
2627 if ! ok {
28+ internal .Logger .Printf (ctx , "hitless: invalid notification type format: %v" , notification [0 ])
2729 return ErrInvalidNotification
2830 }
2931
@@ -60,16 +62,19 @@ func (snh *NotificationHandler) HandlePushNotification(ctx context.Context, hand
6062// ["MOVING", seqNum, timeS, endpoint] - per-connection handoff
6163func (snh * NotificationHandler ) handleMoving (ctx context.Context , handlerCtx push.NotificationHandlerContext , notification []interface {}) error {
6264 if len (notification ) < 3 {
65+ internal .Logger .Printf (ctx , "hitless: invalid MOVING notification: %v" , notification )
6366 return ErrInvalidNotification
6467 }
6568 seqID , ok := notification [1 ].(int64 )
6669 if ! ok {
70+ internal .Logger .Printf (ctx , "hitless: invalid seqID in MOVING notification: %v" , notification [1 ])
6771 return ErrInvalidNotification
6872 }
6973
7074 // Extract timeS
7175 timeS , ok := notification [2 ].(int64 )
7276 if ! ok {
77+ internal .Logger .Printf (ctx , "hitless: invalid timeS in MOVING notification: %v" , notification [2 ])
7378 return ErrInvalidNotification
7479 }
7580
@@ -78,13 +83,15 @@ func (snh *NotificationHandler) handleMoving(ctx context.Context, handlerCtx pus
7883 // Extract new endpoint
7984 newEndpoint , ok = notification [3 ].(string )
8085 if ! ok {
86+ internal .Logger .Printf (ctx , "hitless: invalid newEndpoint in MOVING notification: %v" , notification [3 ])
8187 return ErrInvalidNotification
8288 }
8389 }
8490
8591 // Get the connection that received this notification
8692 conn := handlerCtx .Conn
8793 if conn == nil {
94+ internal .Logger .Printf (ctx , "hitless: no connection in handler context for MOVING notification" )
8895 return ErrInvalidNotification
8996 }
9097
@@ -95,6 +102,7 @@ func (snh *NotificationHandler) handleMoving(ctx context.Context, handlerCtx pus
95102 } else if pc , ok := conn .(* pool.Conn ); ok {
96103 poolConn = pc
97104 } else {
105+ internal .Logger .Printf (ctx , "hitless: invalid connection type in handler context for MOVING notification - %T %#v" , conn , handlerCtx )
98106 return ErrInvalidNotification
99107 }
100108
@@ -145,17 +153,20 @@ func (snh *NotificationHandler) handleMigrating(ctx context.Context, handlerCtx
145153 // MIGRATING notifications indicate that a connection is about to be migrated
146154 // Apply relaxed timeouts to the specific connection that received this notification
147155 if len (notification ) < 2 {
156+ internal .Logger .Printf (ctx , "hitless: invalid MIGRATING notification: %v" , notification )
148157 return ErrInvalidNotification
149158 }
150159
151160 // Get the connection from handler context and type assert to connectionAdapter
152161 if handlerCtx .Conn == nil {
162+ internal .Logger .Printf (ctx , "hitless: no connection in handler context for MIGRATING notification" )
153163 return ErrInvalidNotification
154164 }
155165
156166 // Type assert to connectionAdapter which implements ConnectionWithRelaxedTimeout
157167 connAdapter , ok := handlerCtx .Conn .(interfaces.ConnectionWithRelaxedTimeout )
158168 if ! ok {
169+ internal .Logger .Printf (ctx , "hitless: invalid connection type in handler context for MIGRATING notification" )
159170 return ErrInvalidNotification
160171 }
161172
@@ -169,17 +180,20 @@ func (snh *NotificationHandler) handleMigrated(ctx context.Context, handlerCtx p
169180 // MIGRATED notifications indicate that a connection migration has completed
170181 // Restore normal timeouts for the specific connection that received this notification
171182 if len (notification ) < 2 {
183+ internal .Logger .Printf (ctx , "hitless: invalid MIGRATED notification: %v" , notification )
172184 return ErrInvalidNotification
173185 }
174186
175187 // Get the connection from handler context and type assert to connectionAdapter
176188 if handlerCtx .Conn == nil {
189+ internal .Logger .Printf (ctx , "hitless: no connection in handler context for MIGRATED notification" )
177190 return ErrInvalidNotification
178191 }
179192
180193 // Type assert to connectionAdapter which implements ConnectionWithRelaxedTimeout
181194 connAdapter , ok := handlerCtx .Conn .(interfaces.ConnectionWithRelaxedTimeout )
182195 if ! ok {
196+ internal .Logger .Printf (ctx , "hitless: invalid connection type in handler context for MIGRATED notification" )
183197 return ErrInvalidNotification
184198 }
185199
@@ -193,17 +207,20 @@ func (snh *NotificationHandler) handleFailingOver(ctx context.Context, handlerCt
193207 // FAILING_OVER notifications indicate that a connection is about to failover
194208 // Apply relaxed timeouts to the specific connection that received this notification
195209 if len (notification ) < 2 {
210+ internal .Logger .Printf (ctx , "hitless: invalid FAILING_OVER notification: %v" , notification )
196211 return ErrInvalidNotification
197212 }
198213
199214 // Get the connection from handler context and type assert to connectionAdapter
200215 if handlerCtx .Conn == nil {
216+ internal .Logger .Printf (ctx , "hitless: no connection in handler context for FAILING_OVER notification" )
201217 return ErrInvalidNotification
202218 }
203219
204220 // Type assert to connectionAdapter which implements ConnectionWithRelaxedTimeout
205221 connAdapter , ok := handlerCtx .Conn .(interfaces.ConnectionWithRelaxedTimeout )
206222 if ! ok {
223+ internal .Logger .Printf (ctx , "hitless: invalid connection type in handler context for FAILING_OVER notification" )
207224 return ErrInvalidNotification
208225 }
209226
@@ -217,17 +234,20 @@ func (snh *NotificationHandler) handleFailedOver(ctx context.Context, handlerCtx
217234 // FAILED_OVER notifications indicate that a connection failover has completed
218235 // Restore normal timeouts for the specific connection that received this notification
219236 if len (notification ) < 2 {
237+ internal .Logger .Printf (ctx , "hitless: invalid FAILED_OVER notification: %v" , notification )
220238 return ErrInvalidNotification
221239 }
222240
223241 // Get the connection from handler context and type assert to connectionAdapter
224242 if handlerCtx .Conn == nil {
243+ internal .Logger .Printf (ctx , "hitless: no connection in handler context for FAILED_OVER notification" )
225244 return ErrInvalidNotification
226245 }
227246
228247 // Type assert to connectionAdapter which implements ConnectionWithRelaxedTimeout
229248 connAdapter , ok := handlerCtx .Conn .(interfaces.ConnectionWithRelaxedTimeout )
230249 if ! ok {
250+ internal .Logger .Printf (ctx , "hitless: invalid connection type in handler context for FAILED_OVER notification" )
231251 return ErrInvalidNotification
232252 }
233253
0 commit comments