-
Notifications
You must be signed in to change notification settings - Fork 0
/
dispatcher.go
46 lines (40 loc) · 1.2 KB
/
dispatcher.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package notifyevent
import (
"github.com/tim-ywliu/event"
"github.com/nycu-ucr/openapi/models"
"github.com/nycu-ucr/pcf/logger"
)
var notifyDispatcher *event.Dispatcher
func RegisterNotifyDispatcher() error {
notifyDispatcher = event.NewDispatcher()
if err := notifyDispatcher.Register(NotifyListener{},
SendSMpolicyUpdateNotifyEventName,
SendSMpolicyTerminationNotifyEventName); err != nil {
return err
}
return nil
}
func DispatchSendSMPolicyUpdateNotifyEvent(uri string, request *models.SmPolicyNotification) {
if notifyDispatcher == nil {
logger.NotifyEventLog.Errorf("notifyDispatcher is nil")
}
err := notifyDispatcher.Dispatch(SendSMpolicyUpdateNotifyEventName, SendSMpolicyUpdateNotifyEvent{
uri: uri,
request: request,
})
if err != nil {
logger.NotifyEventLog.Errorln(err)
}
}
func DispatchSendSMPolicyTerminationNotifyEvent(uri string, request *models.TerminationNotification) {
if notifyDispatcher == nil {
logger.NotifyEventLog.Errorf("notifyDispatcher is nil")
}
err := notifyDispatcher.Dispatch(SendSMpolicyTerminationNotifyEventName, SendSMpolicyTerminationNotifyEvent{
uri: uri,
request: request,
})
if err != nil {
logger.NotifyEventLog.Errorln(err)
}
}