liuxiaolong
2020-03-11 7848ce12f101f8e825b01a52e620f75514900ea9
ret cliInfo
2个文件已修改
30 ■■■■■ 已修改文件
mangos.go 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pubsub.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
mangos.go
@@ -13,6 +13,11 @@
    pubCh        chan Message  //publish msg chan
    surveyors    gopherdiscovery.StringSet
    svr *gopherdiscovery.DiscoveryServer
    cli *gopherdiscovery.DiscoveryClient
    cliInfo map[string]interface{}
    recvCh chan Message  //recv msg chan
}
@@ -22,9 +27,8 @@
    var err error
    var (
        defaultOpts = gopherdiscovery.Options{
            SurveyTime:   3 * time.Second,
            //RecvDeadline: 3 * time.Second,
            PollTime:     5 * time.Second,
            SurveyTime:   1500 * time.Millisecond,
            PollTime:     2 * time.Second,
        }
    )
@@ -36,6 +40,7 @@
        heartBeatUrl: heartBeatUrl,
        surveyors:    gopherdiscovery.NewStringSet(),
        pubCh:        make(chan Message, 50),
        svr: discoveryServer,
    }
    var msgCache = make(map[string]Message)
    //clientMsgCh := make(map[string]chan Message)
@@ -76,6 +81,7 @@
                }
                pub.surveyors = nodeIds
                pub.cliInfo = discoveryServer.SvInfo()
                time.Sleep(10 * time.Millisecond)
            }
        }
@@ -101,6 +107,7 @@
        heartBeatUrl: heartBeatUrl,
        recvCh: make(chan Message,50),
        surveyors: gopherdiscovery.NewStringSet(),
        cli: client,
    }
    var receivedCache = make(map[string]string)
    go func() {
@@ -150,3 +157,16 @@
func (ps *mangosPubSub) Recv() chan Message {
    return ps.recvCh
}
func (ps *mangosPubSub) GetCliInfo() map[string]interface{} {
    if ps.svr != nil {
        return ps.cliInfo
    }
    return nil
}
func (ps *mangosPubSub) SetResp(r interface{}) {
    if ps.cli != nil {
        ps.cli.SetResp(r)
    }
}
pubsub.go
@@ -7,6 +7,10 @@
    Surveyor() []string
    Recv() chan Message
    GetCliInfo() map[string]interface{}
    SetResp(interface{})
}
type Message struct {