Skip to content

Commit

Permalink
Review comments #1.
Browse files Browse the repository at this point in the history
  • Loading branch information
easwars committed Feb 12, 2020
1 parent b007934 commit 54f280b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions clientconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
"google.golang.org/grpc/internal/backoff"
"google.golang.org/grpc/internal/channelz"
"google.golang.org/grpc/internal/grpcsync"
internaltarget "google.golang.org/grpc/internal/target"
"google.golang.org/grpc/internal/grpcutil"
"google.golang.org/grpc/internal/transport"
"google.golang.org/grpc/keepalive"
"google.golang.org/grpc/resolver"
Expand Down Expand Up @@ -242,7 +242,7 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *
}

// Determine the resolver to use.
cc.parsedTarget = internaltarget.Parse(cc.target)
cc.parsedTarget = grpcutil.ParseTarget(cc.target)
grpclog.Infof("parsed scheme: %q", cc.parsedTarget.Scheme)
resolverBuilder := cc.getResolver(cc.parsedTarget.Scheme)
if resolverBuilder == nil {
Expand Down
9 changes: 5 additions & 4 deletions internal/target/target.go → internal/grpcutil/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
*
*/

// Package target provides functionality to parse target URI strings.
package target
// Package grpcutil provides a bunch of utility functions to be used across the
// gRPC codebase.
package grpcutil

import (
"strings"
Expand All @@ -35,12 +36,12 @@ func split2(s, sep string) (string, string, bool) {
return spl[0], spl[1], true
}

// Parse splits target into a resolver.Target struct containing scheme,
// ParseTarget splits target into a resolver.Target struct containing scheme,
// authority and endpoint.
//
// If target is not a valid scheme://authority/endpoint, it returns {Endpoint:
// target}.
func Parse(target string) (ret resolver.Target) {
func ParseTarget(target string) (ret resolver.Target) {
var ok bool
ret.Scheme, ret.Endpoint, ok = split2(target, "://")
if !ok {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*/

package target
package grpcutil

import (
"testing"
Expand All @@ -32,9 +32,9 @@ func TestParseTarget(t *testing.T) {
{Scheme: "passthrough", Authority: "", Endpoint: "/unix/socket/address"},
} {
str := test.Scheme + "://" + test.Authority + "/" + test.Endpoint
got := Parse(str)
got := ParseTarget(str)
if got != test {
t.Errorf("Parse(%q) = %+v, want %+v", str, got, test)
t.Errorf("ParseTarget(%q) = %+v, want %+v", str, got, test)
}
}
}
Expand Down Expand Up @@ -71,9 +71,9 @@ func TestParseTargetString(t *testing.T) {
{targetStr: "a//b", want: resolver.Target{Scheme: "", Authority: "", Endpoint: "a//b"}},
{targetStr: "a://b", want: resolver.Target{Scheme: "", Authority: "", Endpoint: "a://b"}},
} {
got := Parse(test.targetStr)
got := ParseTarget(test.targetStr)
if got != test.want {
t.Errorf("Parse(%q) = %+v, want %+v", test.targetStr, got, test.want)
t.Errorf("ParseTarget(%q) = %+v, want %+v", test.targetStr, got, test.want)
}
}
}

0 comments on commit 54f280b

Please sign in to comment.