You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by di...@apache.org on 2022/04/13 09:17:13 UTC

[rocketmq-client-go] branch master updated: Fix the feature that GetNamesrv (#805)

This is an automated email from the ASF dual-hosted git repository.

dinglei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-client-go.git


The following commit(s) were added to refs/heads/master by this push:
     new b7a7911  Fix the feature that GetNamesrv (#805)
b7a7911 is described below

commit b7a79110ce79c8560ef621b6d3b3733dad61bcc2
Author: guyinyou <36...@users.noreply.github.com>
AuthorDate: Wed Apr 13 17:17:09 2022 +0800

    Fix the feature that GetNamesrv (#805)
    
    * Refactor the client instance struct,converge the namesrv module
    
    * fix the feature that GetNamesrv(clientId)
---
 internal/namesrv.go | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/internal/namesrv.go b/internal/namesrv.go
index 96e708a..3f7d038 100644
--- a/internal/namesrv.go
+++ b/internal/namesrv.go
@@ -97,21 +97,17 @@ type namesrvs struct {
 }
 
 var _ Namesrvs = (*namesrvs)(nil)
-var namesrvMap sync.Map
 
-// NewNamesrv init Namesrv from namesrv addr string.
-// addr primitive.NamesrvAddr
-func GetOrSetNamesrv(clientId string, namesrv *namesrvs) *namesrvs {
-	actual, _ := namesrvMap.LoadOrStore(clientId, namesrv)
-	return actual.(*namesrvs)
-}
 func GetNamesrv(clientId string) (*namesrvs, error) {
-	actual, ok := namesrvMap.Load(clientId)
+	actual, ok := clientMap.Load(clientId)
 	if !ok {
 		return nil, fmt.Errorf("the namesrv in instanceName [%s] not found", clientId)
 	}
-	return actual.(*namesrvs), nil
+	return actual.(*rmqClient).GetNameSrv().(*namesrvs), nil
 }
+
+// NewNamesrv init Namesrv from namesrv addr string.
+// addr primitive.NamesrvAddr
 func NewNamesrv(resolver primitive.NsResolver) (*namesrvs, error) {
 	addr := resolver.Resolve()
 	if len(addr) == 0 {