snapshot of https://github.com/centrifugal/centrifugo.git (master, 2026-09-16; blobs > 131072B omitted)
This commit is contained in:
25
internal/notify/notify.go
Normal file
25
internal/notify/notify.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package notify
|
||||
|
||||
import (
|
||||
"github.com/centrifugal/centrifuge"
|
||||
"github.com/centrifugal/centrifugo/v6/internal/usage"
|
||||
)
|
||||
|
||||
func RegisterHandlers(node *centrifuge.Node, statsSender *usage.Sender) {
|
||||
handlers := map[string]centrifuge.NotificationHandler{
|
||||
usage.LastSentUpdateNotificationOp: func(event centrifuge.NotificationEvent) {
|
||||
if statsSender == nil {
|
||||
// Different configurations on different nodes.
|
||||
return
|
||||
}
|
||||
statsSender.UpdateLastSentAt(event.Data)
|
||||
},
|
||||
}
|
||||
node.OnNotification(func(event centrifuge.NotificationEvent) {
|
||||
h, ok := handlers[event.Op]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
go h(event)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user