Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/grpc/grpc-go
Browse files Browse the repository at this point in the history
  • Loading branch information
iamqizhao committed Jun 30, 2016
2 parents c477cb3 + a0ff1e7 commit 605ce23
Show file tree
Hide file tree
Showing 23 changed files with 2,263 additions and 28 deletions.
2 changes: 1 addition & 1 deletion balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ type roundRobin struct {
func (rr *roundRobin) watchAddrUpdates() error {
updates, err := rr.w.Next()
if err != nil {
grpclog.Println("grpc: the naming watcher stops working due to %v.", err)
grpclog.Printf("grpc: the naming watcher stops working due to %v.\n", err)
return err
}
rr.mu.Lock()
Expand Down
10 changes: 3 additions & 7 deletions benchmark/worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ type byteBufCodec struct {
func (byteBufCodec) Marshal(v interface{}) ([]byte, error) {
b, ok := v.(*[]byte)
if !ok {
return nil, fmt.Errorf("failed to marshal: %v is not type of *[]byte")
return nil, fmt.Errorf("failed to marshal: %v is not type of *[]byte", v)
}
return *b, nil
}

func (byteBufCodec) Unmarshal(data []byte, v interface{}) error {
b, ok := v.(*[]byte)
if !ok {
return fmt.Errorf("failed to marshal: %v is not type of *[]byte")
return fmt.Errorf("failed to marshal: %v is not type of *[]byte", v)
}
*b = data
return nil
Expand Down Expand Up @@ -138,8 +138,6 @@ func (s *workerServer) RunServer(stream testpb.WorkerService_RunServerServer) er
return err
}
}

return nil
}

func (s *workerServer) RunClient(stream testpb.WorkerService_RunClientServer) error {
Expand Down Expand Up @@ -191,13 +189,11 @@ func (s *workerServer) RunClient(stream testpb.WorkerService_RunClientServer) er
return err
}
}

return nil
}

func (s *workerServer) CoreCount(ctx context.Context, in *testpb.CoreRequest) (*testpb.CoreResponse, error) {
grpclog.Printf("core count: %v", runtime.NumCPU())
return &testpb.CoreResponse{int32(runtime.NumCPU())}, nil
return &testpb.CoreResponse{Cores: int32(runtime.NumCPU())}, nil
}

func (s *workerServer) QuitWorker(ctx context.Context, in *testpb.Void) (*testpb.Void, error) {
Expand Down
10 changes: 5 additions & 5 deletions credentials/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type PerRPCCredentials interface {
// TODO(zhaoq): Define the set of the qualified keys instead of leaving
// it as an arbitrary string.
GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error)
// RequireTransportSecurity indicates whether the credentails requires
// RequireTransportSecurity indicates whether the credentials requires
// transport security.
RequireTransportSecurity() bool
}
Expand Down Expand Up @@ -116,7 +116,7 @@ func (t TLSInfo) AuthType() string {
// tlsCreds is the credentials required for authenticating a connection using TLS.
type tlsCreds struct {
// TLS configuration
config tls.Config
config *tls.Config
}

func (c tlsCreds) Info() ProtocolInfo {
Expand Down Expand Up @@ -158,7 +158,7 @@ func (c *tlsCreds) ClientHandshake(addr string, rawConn net.Conn, timeout time.D
}
c.config.ServerName = addr[:colonPos]
}
conn := tls.Client(rawConn, &c.config)
conn := tls.Client(rawConn, c.config)
if timeout == 0 {
err = conn.Handshake()
} else {
Expand All @@ -177,7 +177,7 @@ func (c *tlsCreds) ClientHandshake(addr string, rawConn net.Conn, timeout time.D
}

func (c *tlsCreds) ServerHandshake(rawConn net.Conn) (net.Conn, AuthInfo, error) {
conn := tls.Server(rawConn, &c.config)
conn := tls.Server(rawConn, c.config)
if err := conn.Handshake(); err != nil {
rawConn.Close()
return nil, nil, err
Expand All @@ -187,7 +187,7 @@ func (c *tlsCreds) ServerHandshake(rawConn net.Conn) (net.Conn, AuthInfo, error)

// NewTLS uses c to construct a TransportCredentials based on TLS.
func NewTLS(c *tls.Config) TransportCredentials {
tc := &tlsCreds{*c}
tc := &tlsCreds{c}
tc.config.NextProtos = alpnProtoStr
return tc
}
Expand Down
14 changes: 7 additions & 7 deletions examples/route_guide/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ func runRecordRoute(client pb.RouteGuideClient) {
// runRouteChat receives a sequence of route notes, while sending notes for various locations.
func runRouteChat(client pb.RouteGuideClient) {
notes := []*pb.RouteNote{
{&pb.Point{0, 1}, "First message"},
{&pb.Point{0, 2}, "Second message"},
{&pb.Point{0, 3}, "Third message"},
{&pb.Point{0, 1}, "Fourth message"},
{&pb.Point{0, 2}, "Fifth message"},
{&pb.Point{0, 3}, "Sixth message"},
{&pb.Point{Latitude: 0, Longitude: 1}, "First message"},
{&pb.Point{Latitude: 0, Longitude: 2}, "Second message"},
{&pb.Point{Latitude: 0, Longitude: 3}, "Third message"},
{&pb.Point{Latitude: 0, Longitude: 1}, "Fourth message"},
{&pb.Point{Latitude: 0, Longitude: 2}, "Fifth message"},
{&pb.Point{Latitude: 0, Longitude: 3}, "Sixth message"},
}
stream, err := client.RouteChat(context.Background())
if err != nil {
Expand Down Expand Up @@ -192,7 +192,7 @@ func main() {
printFeature(client, &pb.Point{0, 0})

// Looking for features between 40, -75 and 42, -73.
printFeatures(client, &pb.Rectangle{&pb.Point{400000000, -750000000}, &pb.Point{420000000, -730000000}})
printFeatures(client, &pb.Rectangle{&pb.Point{Latitude: 400000000, Longitude: -750000000}, &pb.Point{Latitude: 420000000, Longitude: -730000000}})

// RecordRoute
runRecordRoute(client)
Expand Down
18 changes: 18 additions & 0 deletions reflection/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Reflection

Package reflection implements server reflection service.

The service implemented is defined in: https://github.com/grpc/grpc/blob/master/src/proto/grpc/reflection/v1alpha/reflection.proto.

To register server reflection on a gRPC server:
```go
import "google.golang.org/grpc/reflection"

s := grpc.NewServer()
pb.RegisterYourOwnServer(s, &server{})

// Register reflection service on gRPC server.
reflection.Register(s)

s.Serve(lis)
```
Loading

0 comments on commit 605ce23

Please sign in to comment.