From d5c8ff820385c55a82a153e6a7a6535f115dce2c Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期一, 25 一月 2021 15:04:27 +0800
Subject: [PATCH] add RequestOnly
---
micronode.go | 4 ++++
hbusc.go | 13 +++++++++++++
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/hbusc.go b/hbusc.go
index 8608efb..e5f7dd6 100644
--- a/hbusc.go
+++ b/hbusc.go
@@ -452,6 +452,19 @@
return nil, fmt.Errorf("request err")
}
+func (h *BHBus) RequestOnly(rData []byte, rNodes []bhomebus.NetNode) ([]byte, error) {
+ var ret []bhomebus.Mesg
+
+ n := h.sockWorker.sock.SendandrecvTimeout(rNodes, rData, &ret, h.conf.sendTimeOut)
+
+ if n > 0 && len(ret) > 0 {
+ return ret[0].Data, nil
+ } else {
+ h.printLog("Request n: ", n, " len(ret): ", len(ret))
+ }
+ return nil, fmt.Errorf("request err")
+}
+
func (h *BHBus) Reply(replyKey int, i *Reply) error {
data,err := json.Marshal(*i)
if err != nil {
diff --git a/micronode.go b/micronode.go
index 53dacf4..04ad27f 100644
--- a/micronode.go
+++ b/micronode.go
@@ -134,6 +134,10 @@
return ms.handle.Request(serverId, msgR, milliSecs)
}
+func (ms *MicroNode) RequestOnly(rData []byte, nodes []bhomebus.NetNode) ([]byte, error) {
+ return ms.handle.RequestOnly(rData, nodes)
+}
+
//鑾峰彇鏈満涓煇涓�涓富棰樼殑 key 锛堢粨鏋滃彧鏈変竴涓厓绱狅級
func (ms *MicroNode) GetLocalNetNodeByTopic(topicName string) []bhomebus.NetNode {
netNodes, err := ms.handle.GetNetNodeByTopic(ms.serverId, ms.procInfo, topicName)
--
Gitblit v1.8.0