Skip to content

Commit 3e18a93

Browse files
committed
Try something
1 parent 03036ce commit 3e18a93

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

examples/features/customloadbalancer/client/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
"google.golang.org/grpc"
2929
"google.golang.org/grpc/credentials/insecure"
3030
_ "google.golang.org/grpc/examples/features/customloadbalancer/client/customroundrobin" // To register custom_round_robin.
31-
"google.golang.org/grpc/examples/features/proto/echo"
31+
pb "google.golang.org/grpc/examples/features/proto/echo"
3232
"google.golang.org/grpc/internal"
3333
"google.golang.org/grpc/peer"
3434
"google.golang.org/grpc/resolver"
@@ -64,7 +64,7 @@ func main() {
6464
}
6565
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
6666
defer cancel()
67-
ec := echo.NewEchoClient(cc)
67+
ec := pb.NewEchoClient(cc)
6868
if err := waitForDistribution(ctx, ec); err != nil {
6969
log.Fatalf(err.Error())
7070
}
@@ -74,7 +74,7 @@ func main() {
7474
// waitForDistribution makes RPC's on the echo client until 3 RPC's follow the
7575
// same 1:2 address ratio for the peer. Returns an error if fails to do so
7676
// before context timeout.
77-
func waitForDistribution(ctx context.Context, ec echo.EchoClient) error {
77+
func waitForDistribution(ctx context.Context, ec pb.EchoClient) error {
7878
for {
7979
results := make(map[string]uint32)
8080
InnerLoop:
@@ -87,7 +87,7 @@ func waitForDistribution(ctx context.Context, ec echo.EchoClient) error {
8787
res := make(map[string]uint32)
8888
for j := 0; j < 3; j++ {
8989
var peer peer.Peer
90-
r, err := ec.UnaryEcho(ctx, &echo.EchoRequest{Message: "this is examples/customloadbalancing"}, grpc.Peer(&peer))
90+
r, err := ec.UnaryEcho(ctx, &pb.EchoRequest{Message: "this is examples/customloadbalancing"}, grpc.Peer(&peer))
9191
if err != nil {
9292
return fmt.Errorf("UnaryEcho failed: %v", err)
9393
}

examples/features/customloadbalancer/server/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ import (
2626
"sync"
2727

2828
"google.golang.org/grpc"
29-
"google.golang.org/grpc/examples/features/proto/echo"
29+
pb "google.golang.org/grpc/examples/features/proto/echo"
3030
)
3131

3232
var (
3333
addrs = []string{"localhost:20000", "localhost:20001"}
3434
)
3535

3636
type echoServer struct {
37-
echo.UnimplementedEchoServer
37+
pb.UnimplementedEchoServer
3838
addr string
3939
}
4040

41-
func (s *echoServer) UnaryEcho(ctx context.Context, req *echo.EchoRequest) (*echo.EchoResponse, error) {
42-
return &echo.EchoResponse{Message: fmt.Sprintf("%s (from %s)", req.Message, s.addr)}, nil
41+
func (s *echoServer) UnaryEcho(ctx context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) {
42+
return &pb.EchoResponse{Message: fmt.Sprintf("%s (from %s)", req.Message, s.addr)}, nil
4343
}
4444

4545
func main() {
@@ -50,7 +50,7 @@ func main() {
5050
log.Fatalf("failed to listen: %v", err)
5151
}
5252
s := grpc.NewServer()
53-
echo.RegisterEchoServer(s, &echoServer{
53+
pb.RegisterEchoServer(s, &echoServer{
5454
addr: addr,
5555
})
5656
log.Printf("serving on %s\n", addr)

0 commit comments

Comments
 (0)