rocketmq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jianha...@apache.org
Subject [rocketmq-client-go] 01/01: Revert "Feat/resolver"
Date Thu, 03 Dec 2020 10:23:13 GMT
This is an automated email from the ASF dual-hosted git repository.

jianhaixu pushed a commit to branch revert-552-feat/resolver
in repository https://gitbox.apache.org/repos/asf/rocketmq-client-go.git

commit 8fca568a75d717fb514fb25718b5cbbb66b66038
Author: xujianhai666 <52450794+xujianhai666@users.noreply.github.com>
AuthorDate: Thu Dec 3 18:23:05 2020 +0800

    Revert "Feat/resolver"
---
 primitive/nsresolver.go      | 39 ---------------------------------------
 primitive/nsresolver_test.go | 18 ------------------
 2 files changed, 57 deletions(-)

diff --git a/primitive/nsresolver.go b/primitive/nsresolver.go
index a0ab830..d844373 100644
--- a/primitive/nsresolver.go
+++ b/primitive/nsresolver.go
@@ -19,7 +19,6 @@ package primitive
 import (
 	"fmt"
 	"io/ioutil"
-	"net"
 	"net/http"
 	"os"
 	"os/user"
@@ -83,44 +82,6 @@ func (p *passthroughResolver) Description() string {
 	return fmt.Sprintf("passthrough resolver of %v", p.addr)
 }
 
-type dnsResolver struct {
-	addrs    []string
-	failback NsResolver
-}
-
-func NewDNSResolver(addrs []string) *dnsResolver {
-	return &dnsResolver{
-		addrs:    addrs,
-		failback: NewEnvResolver(),
-	}
-}
-
-func (p *dnsResolver) Resolve() []string {
-	finalAddrs := make([]string, 0, len(p.addrs))
-	for _, addr := range p.addrs {
-		// example.com:9876
-		domainPort := strings.Split(addr, ":")
-		if len(domainPort) != 2 {
-			continue
-		}
-		ns, err := net.LookupHost(domainPort[0])
-		if err != nil {
-			continue
-		}
-		for _, host := range ns {
-			finalAddrs = append(finalAddrs, host+":"+domainPort[1])
-		}
-	}
-	if len(finalAddrs) > 0 {
-		return finalAddrs
-	}
-	return p.failback.Resolve()
-}
-
-func (p *dnsResolver) Description() string {
-	return fmt.Sprintf("dns resolver of %v", p.addrs)
-}
-
 const (
 	DEFAULT_NAMESRV_ADDR = "http://jmenv.tbsite.net:8080/rocketmq/nsaddr"
 )
diff --git a/primitive/nsresolver_test.go b/primitive/nsresolver_test.go
index 68bb955..98d839a 100644
--- a/primitive/nsresolver_test.go
+++ b/primitive/nsresolver_test.go
@@ -131,21 +131,3 @@ func TesHttpReslverWithSnapshotFileOnce(t *testing.T) {
 		So(Diff(addrs1, srvs), ShouldBeFalse)
 	})
 }
-
-func TestDNSResolver(t *testing.T) {
-	Convey("Test UpdateNameServerAddress Use DNS", t, func() {
-		srvs := []string{
-			"examples.com:9876",
-		}
-
-		hosts, _ := net.LookupHost("examples.com")
-		expectedHosts := make([]string, 0)
-		for _, host := range hosts {
-			expectedHosts = append(expectedHosts, host+":9876")
-		}
-		resolver := NewDNSResolver(srvs)
-		addrs := resolver.Resolve()
-
-		So(Diff(expectedHosts, addrs), ShouldBeFalse)
-	})
-}


Mime
View raw message