当玩家id为0,说明是登陆或注册消息,随机挑选一个该类型下的节点发消息。
This commit is contained in:
parent
94b2989521
commit
76e86c9f06
@ -114,10 +114,16 @@ func (m *UserBindService) RandServiceNode(typeId pb.ServiceTypeId) (*etcd.Servic
|
||||
|
||||
// 根据服务类型,路由到对应的服务节点
|
||||
func (m *UserBindService) FindServiceName(userId int64, typeId pb.ServiceTypeId) (string, error) {
|
||||
// 内存中没有,向redis中查询。redis中保留的服务节点不一定是可用的,还需要向etcd中验证
|
||||
if sName := m.LoadFromRedis(userId, typeId); sName != "" && m.serviceIsValid(sName) {
|
||||
if userId > 0 {
|
||||
// 向redis中查询。redis中保留的服务节点不一定是可用的,还需要向etcd中验证
|
||||
sName := m.LoadFromRedis(userId, typeId)
|
||||
// log.DebugF("user:%v查找到服务节点:%s", userId, sName)
|
||||
if sName != "" && m.serviceIsValid(sName) {
|
||||
return sName, nil
|
||||
}
|
||||
}
|
||||
|
||||
// log.DebugF("user:%v查找到服务节点:%s为无效节点", userId, sName)
|
||||
// redis也没有玩家的服务节点信息,从etcd中找可用服务节点随机选择一个
|
||||
node, err := m.RandServiceNode(typeId)
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user