forked from TarsCloud/TarsGo
-
Notifications
You must be signed in to change notification settings - Fork 4
/
notifyf.go
58 lines (53 loc) · 1.3 KB
/
notifyf.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
47
48
49
50
51
52
53
54
55
56
57
58
package tars
import "tars/protocol/res/notifyf"
//NotifyHelper is the helper struct for the Notify service.
type NotifyHelper struct {
comm *Communicator
tn *notifyf.Notify
tm notifyf.ReportInfo
}
//SetNotifyInfo sets the notify server location for the Communicator.
func (n *NotifyHelper) SetNotifyInfo(comm *Communicator, notify string, app string, server string, container string) {
n.comm = comm
n.comm.SetProperty("netthread", 1)
n.tn = new(notifyf.Notify)
comm.StringToProxy(notify, n.tn)
//TODO:params
var set string
if v, ok := comm.GetProperty("setdivision"); ok {
set = v
}
n.tm = notifyf.ReportInfo{
0,
app,
set,
container,
server,
"",
"",
0,
}
}
//ReportNotifyInfo report the info to the notify server.
func (n *NotifyHelper) ReportNotifyInfo(info string) {
n.tm.SMessage = info
TLOG.Debug(n.tm)
n.tn.ReportNotifyInfo(&n.tm)
}
func reportNotifyInfo(info string) {
ha := new(NotifyHelper)
comm := NewCommunicator()
comm.SetProperty("netthread", 1)
notify := GetServerConfig().notify
app := GetServerConfig().App
server := GetServerConfig().Server
container := GetServerConfig().Container
//container := ""
ha.SetNotifyInfo(comm, notify, app, server, container)
defer func() {
if err := recover(); err != nil {
TLOG.Debug(err)
}
}()
ha.ReportNotifyInfo(info)
}