-
Notifications
You must be signed in to change notification settings - Fork 0
/
bus.etcd.go
44 lines (39 loc) · 1.12 KB
/
bus.etcd.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
package robot
import (
libconsts "social/lib/consts"
libetcd "social/lib/etcd"
pkgserver "social/pkg/server"
"strconv"
)
// OnEventEtcd 处理事件-etcd
func (p *Bus) OnEventEtcd(key string, value string) error {
robot.LogMgr.Infof("%v key:%v, value:%v", libconsts.Etcd, key, value)
var zoneIDU32 uint32
var serviceIDU32 uint32
msgType, zoneID, serviceName, serviceID := libetcd.Parse(key)
if zoneIDU64, err := strconv.ParseUint(zoneID, 10, 32); err != nil {
robot.LogMgr.Errorf(libconsts.Etcd, key, value, err)
return nil
} else {
zoneIDU32 = uint32(zoneIDU64)
}
switch msgType {
case libetcd.WatchMsgTypeCommand:
case libetcd.WatchMsgTypeService:
if serviceIDU64, err := strconv.ParseUint(serviceID, 10, 64); err != nil {
robot.LogMgr.Fatal(libconsts.Etcd, key, value, serviceID, err)
return nil
} else {
serviceIDU32 = uint32(serviceIDU64)
}
switch serviceName {
// 收到其它 服务 启动、关闭 的信息
case pkgserver.NameGate: //网关
// todo menglingchao 筛选,链接
robot.LogMgr.Info(key, value, zoneIDU32, serviceName, serviceIDU32)
default:
}
default:
}
return nil
}