@@ -19,11 +19,13 @@ type NotificationHandler struct {
19
19
// HandlePushNotification processes push notifications with hook support.
20
20
func (snh * NotificationHandler ) HandlePushNotification (ctx context.Context , handlerCtx push.NotificationHandlerContext , notification []interface {}) error {
21
21
if len (notification ) == 0 {
22
+ internal .Logger .Printf (ctx , "hitless: invalid notification format: %v" , notification )
22
23
return ErrInvalidNotification
23
24
}
24
25
25
26
notificationType , ok := notification [0 ].(string )
26
27
if ! ok {
28
+ internal .Logger .Printf (ctx , "hitless: invalid notification type format: %v" , notification [0 ])
27
29
return ErrInvalidNotification
28
30
}
29
31
@@ -60,16 +62,19 @@ func (snh *NotificationHandler) HandlePushNotification(ctx context.Context, hand
60
62
// ["MOVING", seqNum, timeS, endpoint] - per-connection handoff
61
63
func (snh * NotificationHandler ) handleMoving (ctx context.Context , handlerCtx push.NotificationHandlerContext , notification []interface {}) error {
62
64
if len (notification ) < 3 {
65
+ internal .Logger .Printf (ctx , "hitless: invalid MOVING notification: %v" , notification )
63
66
return ErrInvalidNotification
64
67
}
65
68
seqID , ok := notification [1 ].(int64 )
66
69
if ! ok {
70
+ internal .Logger .Printf (ctx , "hitless: invalid seqID in MOVING notification: %v" , notification [1 ])
67
71
return ErrInvalidNotification
68
72
}
69
73
70
74
// Extract timeS
71
75
timeS , ok := notification [2 ].(int64 )
72
76
if ! ok {
77
+ internal .Logger .Printf (ctx , "hitless: invalid timeS in MOVING notification: %v" , notification [2 ])
73
78
return ErrInvalidNotification
74
79
}
75
80
@@ -78,13 +83,15 @@ func (snh *NotificationHandler) handleMoving(ctx context.Context, handlerCtx pus
78
83
// Extract new endpoint
79
84
newEndpoint , ok = notification [3 ].(string )
80
85
if ! ok {
86
+ internal .Logger .Printf (ctx , "hitless: invalid newEndpoint in MOVING notification: %v" , notification [3 ])
81
87
return ErrInvalidNotification
82
88
}
83
89
}
84
90
85
91
// Get the connection that received this notification
86
92
conn := handlerCtx .Conn
87
93
if conn == nil {
94
+ internal .Logger .Printf (ctx , "hitless: no connection in handler context for MOVING notification" )
88
95
return ErrInvalidNotification
89
96
}
90
97
@@ -95,6 +102,7 @@ func (snh *NotificationHandler) handleMoving(ctx context.Context, handlerCtx pus
95
102
} else if pc , ok := conn .(* pool.Conn ); ok {
96
103
poolConn = pc
97
104
} else {
105
+ internal .Logger .Printf (ctx , "hitless: invalid connection type in handler context for MOVING notification - %T %#v" , conn , handlerCtx )
98
106
return ErrInvalidNotification
99
107
}
100
108
@@ -145,17 +153,20 @@ func (snh *NotificationHandler) handleMigrating(ctx context.Context, handlerCtx
145
153
// MIGRATING notifications indicate that a connection is about to be migrated
146
154
// Apply relaxed timeouts to the specific connection that received this notification
147
155
if len (notification ) < 2 {
156
+ internal .Logger .Printf (ctx , "hitless: invalid MIGRATING notification: %v" , notification )
148
157
return ErrInvalidNotification
149
158
}
150
159
151
160
// Get the connection from handler context and type assert to connectionAdapter
152
161
if handlerCtx .Conn == nil {
162
+ internal .Logger .Printf (ctx , "hitless: no connection in handler context for MIGRATING notification" )
153
163
return ErrInvalidNotification
154
164
}
155
165
156
166
// Type assert to connectionAdapter which implements ConnectionWithRelaxedTimeout
157
167
connAdapter , ok := handlerCtx .Conn .(interfaces.ConnectionWithRelaxedTimeout )
158
168
if ! ok {
169
+ internal .Logger .Printf (ctx , "hitless: invalid connection type in handler context for MIGRATING notification" )
159
170
return ErrInvalidNotification
160
171
}
161
172
@@ -169,17 +180,20 @@ func (snh *NotificationHandler) handleMigrated(ctx context.Context, handlerCtx p
169
180
// MIGRATED notifications indicate that a connection migration has completed
170
181
// Restore normal timeouts for the specific connection that received this notification
171
182
if len (notification ) < 2 {
183
+ internal .Logger .Printf (ctx , "hitless: invalid MIGRATED notification: %v" , notification )
172
184
return ErrInvalidNotification
173
185
}
174
186
175
187
// Get the connection from handler context and type assert to connectionAdapter
176
188
if handlerCtx .Conn == nil {
189
+ internal .Logger .Printf (ctx , "hitless: no connection in handler context for MIGRATED notification" )
177
190
return ErrInvalidNotification
178
191
}
179
192
180
193
// Type assert to connectionAdapter which implements ConnectionWithRelaxedTimeout
181
194
connAdapter , ok := handlerCtx .Conn .(interfaces.ConnectionWithRelaxedTimeout )
182
195
if ! ok {
196
+ internal .Logger .Printf (ctx , "hitless: invalid connection type in handler context for MIGRATED notification" )
183
197
return ErrInvalidNotification
184
198
}
185
199
@@ -193,17 +207,20 @@ func (snh *NotificationHandler) handleFailingOver(ctx context.Context, handlerCt
193
207
// FAILING_OVER notifications indicate that a connection is about to failover
194
208
// Apply relaxed timeouts to the specific connection that received this notification
195
209
if len (notification ) < 2 {
210
+ internal .Logger .Printf (ctx , "hitless: invalid FAILING_OVER notification: %v" , notification )
196
211
return ErrInvalidNotification
197
212
}
198
213
199
214
// Get the connection from handler context and type assert to connectionAdapter
200
215
if handlerCtx .Conn == nil {
216
+ internal .Logger .Printf (ctx , "hitless: no connection in handler context for FAILING_OVER notification" )
201
217
return ErrInvalidNotification
202
218
}
203
219
204
220
// Type assert to connectionAdapter which implements ConnectionWithRelaxedTimeout
205
221
connAdapter , ok := handlerCtx .Conn .(interfaces.ConnectionWithRelaxedTimeout )
206
222
if ! ok {
223
+ internal .Logger .Printf (ctx , "hitless: invalid connection type in handler context for FAILING_OVER notification" )
207
224
return ErrInvalidNotification
208
225
}
209
226
@@ -217,17 +234,20 @@ func (snh *NotificationHandler) handleFailedOver(ctx context.Context, handlerCtx
217
234
// FAILED_OVER notifications indicate that a connection failover has completed
218
235
// Restore normal timeouts for the specific connection that received this notification
219
236
if len (notification ) < 2 {
237
+ internal .Logger .Printf (ctx , "hitless: invalid FAILED_OVER notification: %v" , notification )
220
238
return ErrInvalidNotification
221
239
}
222
240
223
241
// Get the connection from handler context and type assert to connectionAdapter
224
242
if handlerCtx .Conn == nil {
243
+ internal .Logger .Printf (ctx , "hitless: no connection in handler context for FAILED_OVER notification" )
225
244
return ErrInvalidNotification
226
245
}
227
246
228
247
// Type assert to connectionAdapter which implements ConnectionWithRelaxedTimeout
229
248
connAdapter , ok := handlerCtx .Conn .(interfaces.ConnectionWithRelaxedTimeout )
230
249
if ! ok {
250
+ internal .Logger .Printf (ctx , "hitless: invalid connection type in handler context for FAILED_OVER notification" )
231
251
return ErrInvalidNotification
232
252
}
233
253
0 commit comments