Skip to content

Commit efc9692

Browse files
committed
Temp commit
1 parent 72944f9 commit efc9692

File tree

6 files changed

+11
-29
lines changed

6 files changed

+11
-29
lines changed

client/client.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,10 @@ type ServiceCli interface {
2727
// only needs to be called once, on any of those instances.
2828
EnableHistogram()
2929

30-
// EnableResolveFullEps enables to resolve full endpoints.
31-
// Deprecated: This method will be removed in future.
32-
EnableResolveFullEps()
33-
3430
// EnableFailFast makes service client doesn't wait for service to become
3531
// available in Start().
3632
EnableFailFast()
3733

38-
// DisableResolveFullEps disables resolving full endpoints.
39-
// Deprecated: This method will be removed in future.
40-
DisableResolveFullEps()
41-
4234
// AddUnaryInterceptor adds a unary client interceptor to the client.
4335
AddUnaryInterceptor(incept grpc.UnaryClientInterceptor)
4436

client/locator.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/binchencoder/letsgo/flags"
88
"github.com/binchencoder/skylb-apiv2/client/option"
99
"github.com/binchencoder/skylb-apiv2/naming"
10+
"github.com/binchencoder/skylb-apiv2/resolver"
1011

1112
"github.com/binchencoder/skylb-apiv2/internal/skylb"
1213
pb "github.com/binchencoder/skylb-apiv2/proto"
@@ -23,6 +24,8 @@ var (
2324

2425
func init() {
2526
flag.Var(&DebugSvcEndpoints, "debug-svc-endpoint", "The debug service endpoint. If not empty, disable SkyLB resolving for that service.")
27+
28+
resolver.Register()
2629
}
2730

2831
// ServiceLocator defines the interface through which the client app locates

internal/rpccli/rpc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func NewGrpcClient(ctx context.Context) (pb.SkylbClient, error) {
5151
}
5252
glog.Infof("Resolved SkyLB instances %s", addrs)
5353

54+
// TODO(chenbin) 这里不要随机取
5455
switch len(addrs) {
5556
case 0:
5657
return nil, fmt.Errorf("No SkyLB instances found")

resolver/internal/directbuilder.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@ package internal
33
import (
44
"strings"
55

6-
pb "github.com/binchencoder/skylb-apiv2/proto"
76
"google.golang.org/grpc/resolver"
87
)
98

10-
type directBuilder struct {
11-
endpoint *pb.InstanceEndpoint
12-
spec *pb.ServiceSpec
13-
}
9+
type directBuilder struct{}
1410

1511
// Build
1612
func (d *directBuilder) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (
@@ -31,7 +27,7 @@ func (d *directBuilder) Build(target resolver.Target, cc resolver.ClientConn, op
3127
return nil, err
3228
}
3329

34-
return &nopResolver{cc: cc}, nil
30+
return &skylbResolver{cc: cc}, nil
3531
}
3632

3733
func (b *directBuilder) Scheme() string {

resolver/internal/resolver.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,12 @@ var (
3737
directResolverBuilder directBuilder
3838
)
3939

40-
// RegisterResolver registers the skylb schemes to the resolver.
40+
// RegisterResolver registers the direct and skylb schemes to the resolver.
4141
func RegisterResolver() {
4242
resolver.Register(&directResolverBuilder)
4343
resolver.Register(&skylbResolverBuilder)
4444
}
4545

46-
type skylbResolver struct {
47-
cc resolver.ClientConn
48-
}
49-
50-
func (r *skylbResolver) Close() {
51-
}
52-
53-
func (r *skylbResolver) ResolveNow(options resolver.ResolveNowOptions) {
54-
}
55-
5646
type nopResolver struct {
5747
cc resolver.ClientConn
5848
}

resolver/target.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ import (
99

1010
// BuildSkyLBTarget returns a string that represents the given endpoints with skylb schema.
1111
func BuildSkyLBTarget(addrs string) string {
12-
if len(addrs) == 0 {
12+
addrs = strings.TrimSpace(addrs)
13+
if addrs == "" {
1314
return addrs
1415
}
1516

16-
addrs = strings.TrimSpace(addrs)
1717
return fmt.Sprintf("%s://%s", internal.SkyLBScheme, addrs)
1818
}
1919

2020
// BuildDirectTarget returns a string that represents the given endpoints with direct schema.
2121
func BuildDirectTarget(addrs string) string {
22-
if len(addrs) == 0 {
22+
addrs = strings.TrimSpace(addrs)
23+
if addrs == "" {
2324
return addrs
2425
}
2526

26-
addrs = strings.TrimSpace(addrs)
2727
return fmt.Sprintf("%s://%s", internal.DirectScheme, addrs)
2828
}

0 commit comments

Comments
 (0)