rocketmq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ding...@apache.org
Subject [rocketmq-client-go] branch master updated: [ISSUE #473] support nsresolver in TraceConfig
Date Mon, 27 Apr 2020 06:00:49 GMT
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 ef5bda6  [ISSUE #473] support nsresolver in TraceConfig
ef5bda6 is described below

commit ef5bda66b86a9c4fb5e0badbd2b875fc1995c756
Author: linxin <marklin.hz@gmail.com>
AuthorDate: Mon Apr 27 14:00:43 2020 +0800

    [ISSUE #473] support nsresolver in TraceConfig
    
    keep NamesrvAddrs config and add Resolver for TraceConfig
---
 examples/consumer/trace/main.go |  4 ++--
 examples/producer/trace/main.go |  4 ++--
 internal/trace.go               | 13 ++++++++++++-
 primitive/trace.go              |  1 +
 4 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/examples/consumer/trace/main.go b/examples/consumer/trace/main.go
index 35c4926..4daaa9f 100644
--- a/examples/consumer/trace/main.go
+++ b/examples/consumer/trace/main.go
@@ -31,8 +31,8 @@ import (
 func main() {
 	namesrvs := []string{"127.0.0.1:9876"}
 	traceCfg := &primitive.TraceConfig{
-		Access:       primitive.Local,
-		NamesrvAddrs: namesrvs,
+		Access:   primitive.Local,
+		Resolver: primitive.NewPassthroughResolver(namesrvs),
 	}
 
 	c, _ := rocketmq.NewPushConsumer(
diff --git a/examples/producer/trace/main.go b/examples/producer/trace/main.go
index 5f2c9b3..e6a25a9 100644
--- a/examples/producer/trace/main.go
+++ b/examples/producer/trace/main.go
@@ -31,8 +31,8 @@ import (
 func main() {
 	namesrvs := []string{"127.0.0.1:9876"}
 	traceCfg := &primitive.TraceConfig{
-		Access:       primitive.Local,
-		NamesrvAddrs: namesrvs,
+		Access:   primitive.Local,
+		Resolver: primitive.NewPassthroughResolver(namesrvs),
 	}
 
 	p, _ := rocketmq.NewProducer(
diff --git a/internal/trace.go b/internal/trace.go
index f0c643c..321552f 100644
--- a/internal/trace.go
+++ b/internal/trace.go
@@ -241,7 +241,18 @@ func NewTraceDispatcher(traceCfg *primitive.TraceConfig) *traceDispatcher
{
 		t = TraceTopicPrefix + traceCfg.TraceTopic
 	}
 
-	srvs, err := NewNamesrv(primitive.NewPassthroughResolver(traceCfg.NamesrvAddrs))
+	if len(traceCfg.NamesrvAddrs) == 0 && traceCfg.Resolver == nil {
+		panic("no NamesrvAddrs or Resolver configured")
+	}
+
+	var srvs *namesrvs
+	var err error
+	if len(traceCfg.NamesrvAddrs) > 0 {
+		srvs, err = NewNamesrv(primitive.NewPassthroughResolver(traceCfg.NamesrvAddrs))
+	} else {
+		srvs, err = NewNamesrv(traceCfg.Resolver)
+	}
+
 	if err != nil {
 		panic(errors.Wrap(err, "new Namesrv failed."))
 	}
diff --git a/primitive/trace.go b/primitive/trace.go
index c0df5b3..53a13f0 100644
--- a/primitive/trace.go
+++ b/primitive/trace.go
@@ -23,5 +23,6 @@ type TraceConfig struct {
 	GroupName    string
 	Access       AccessChannel
 	NamesrvAddrs []string
+	Resolver     NsResolver
 	Credentials  // acl config for trace. omit if acl is closed on broker.
 }


Mime
View raw message