MCPcopy
hub / github.com/redis/go-redis / PreHook

Method PreHook

maintnotifications/hooks.go:19–41  ·  view source on GitHub ↗

PreHook logs the notification before processing and allows modification.

(ctx context.Context, notificationCtx push.NotificationHandlerContext, notificationType string, notification []interface{})

Source from the content-addressed store, hash-verified

17
18// PreHook logs the notification before processing and allows modification.
19func (lh *LoggingHook) PreHook(ctx context.Context, notificationCtx push.NotificationHandlerContext, notificationType string, notification []interface{}) ([]interface{}, bool) {
20 if lh.LogLevel >= 2 { // Info level
21 // Log the notification type and content
22 connID := uint64(0)
23 if conn, ok := notificationCtx.Conn.(*pool.Conn); ok {
24 connID = conn.GetID()
25 }
26 seqID := int64(0)
27 if slices.Contains(maintenanceNotificationTypes, notificationType) {
28 // seqID is the second element in the notification array
29 if len(notification) > 1 {
30 if parsedSeqID, ok := notification[1].(int64); !ok {
31 seqID = 0
32 } else {
33 seqID = parsedSeqID
34 }
35 }
36
37 }
38 internal.Logger.Printf(ctx, logs.ProcessingNotification(connID, seqID, notificationType, notification))
39 }
40 return notification, true // Continue processing with unmodified notification
41}
42
43// PostHook logs the result after processing.
44func (lh *LoggingHook) PostHook(ctx context.Context, notificationCtx push.NotificationHandlerContext, notificationType string, notification []interface{}, result error) {

Callers

nothing calls this directly

Calls 4

ProcessingNotificationFunction · 0.92
GetIDMethod · 0.80
PrintfMethod · 0.65
ContainsMethod · 0.45

Tested by

no test coverage detected