zhangmeng
2019-05-16 c0dcd1189b06b2f4380f48fa6cf8899cdc945c09
add surveyor time
1个文件已修改
19 ■■■■■ 已修改文件
nng.go 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
nng.go
@@ -33,11 +33,10 @@
        return errors.New("please init NNG first")
    }
    // switch n.sock.GetProtocol().Number() {
    // case mangos.ProtoSurveyor:
    //     time.Sleep(surveyorTime * 2)
    // default:
    // }
    if surveyorTime > 0 {
        time.Sleep(time.Duration(surveyorTime*2) * time.Second)
    }
    if n.raw {
        msg := mangos.NewMessage(len(data))
        msg.Body = data
@@ -121,7 +120,7 @@
// maxRecvSize max recv size
var (
    maxRecvSize  = 33 * 1024 * 1024
    surveyorTime = time.Second / 2
    surveyorTime = -1
)
func defualtSocketOptions() map[string]interface{} {
@@ -156,10 +155,14 @@
        for _, arg := range args {
            switch arg.(type) {
            case int:
                surveyorTime = time.Duration(arg.(int)/2) * time.Second
                if arg.(int) < 2 {
                    surveyorTime = 1
                } else {
                    surveyorTime = arg.(int) / 2
                }
            default:
            }
            options[mangos.OptionSurveyTime] = surveyorTime
            options[mangos.OptionSurveyTime] = time.Duration(surveyorTime) * time.Second
        }
    default:
        fmt.Println("no additional args")