From c0dcd1189b06b2f4380f48fa6cf8899cdc945c09 Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期四, 16 五月 2019 16:11:24 +0800 Subject: [PATCH] add surveyor time --- nng.go | 19 +++++++++++-------- 1 files changed, 11 insertions(+), 8 deletions(-) diff --git a/nng.go b/nng.go index e8f5baf..90ffb4c 100644 --- a/nng.go +++ b/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") -- Gitblit v1.8.0