From 43122190a3adfe763f4df5c1e4be331828e1833d Mon Sep 17 00:00:00 2001 From: duanhf2012 <6549168@qq.com> Date: Wed, 15 Nov 2023 08:48:41 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=96=B0=E5=A2=9EGetNode?= =?UTF-8?q?Info=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cluster/cluster.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cluster/cluster.go b/cluster/cluster.go index c2daaa7..797ddea 100644 --- a/cluster/cluster.go +++ b/cluster/cluster.go @@ -477,3 +477,14 @@ func (cls *Cluster) GetGlobalCfg() interface{} { return cls.globalCfg } +func (cls *Cluster) GetNodeInfo(nodeId int) (NodeInfo,bool) { + cls.locker.RLock() + defer cls.locker.RUnlock() + + nodeInfo,ok:= cls.mapRpc[nodeId] + if ok == false || nodeInfo == nil { + return NodeInfo{},false + } + + return nodeInfo.nodeInfo,true +} From bcbee6dd11cc33c6e186175c722f97b584858097 Mon Sep 17 00:00:00 2001 From: boyce <6549168@qq.com> Date: Mon, 20 Nov 2023 13:32:34 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BC=98=E5=8C=96readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 04aca9b..7b7868c 100644 --- a/README.md +++ b/README.md @@ -1062,7 +1062,7 @@ func (slf *TestTcpService) OnRequest (clientid uint64,msg proto.Message){ 提交bug及特性: https://github.com/duanhf2012/origin/issues [因服务器是由个人维护,如果这个项目对您有帮助,您可以点我进行捐赠,感谢!](http://www.cppblog.com/images/cppblog_com/API/21416/r_pay.jpg "Thanks!") - +![](http://www.cppblog.com/images/cppblog_com/API/21416/r_pay.jpg) 特别感谢以下赞助网友: ``` @@ -1071,4 +1071,5 @@ _ 死磕代码 bp-li 阿正 +大头 ``` From 4898116698a6cafa0aed18de57562b1735a6fafe Mon Sep 17 00:00:00 2001 From: boyce Date: Tue, 27 Feb 2024 16:18:51 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BC=98=E5=8C=96concurrent=EF=BC=8C?= =?UTF-8?q?=E7=A6=81=E6=AD=A2=E9=87=8D=E5=A4=8D=E6=89=93=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- concurrent/concurrent.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/concurrent/concurrent.go b/concurrent/concurrent.go index 6b97059..702c020 100644 --- a/concurrent/concurrent.go +++ b/concurrent/concurrent.go @@ -5,6 +5,7 @@ import ( "runtime" "github.com/duanhf2012/origin/log" + "sync/atomic" ) const defaultMaxTaskChannelNum = 1000000 @@ -21,6 +22,7 @@ type Concurrent struct { tasks chan task cbChannel chan func(error) + open int32 } /* @@ -33,6 +35,10 @@ func (c *Concurrent) OpenConcurrentByNumCPU(cpuNumMul float32) { } func (c *Concurrent) OpenConcurrent(minGoroutineNum int32, maxGoroutineNum int32, maxTaskChannelNum int) { + if atomic.AddInt32(&c.open,1) > 1 { + panic("repeated calls to OpenConcurrent are not allowed!") + } + c.tasks = make(chan task, maxTaskChannelNum) c.cbChannel = make(chan func(error), maxTaskChannelNum)