harlow / go-micro-services

HTTP up front, Protobufs in the rear
MIT License
1.09k stars 165 forks source link

Build problems with metadata errors #12

Closed ghost closed 9 years ago

ghost commented 9 years ago

Hi! I'm using protobuf-3.0.0-beta1

Here is my build log of go-micro-services:

stalker@zombie ~/workspace/src/github.com/harlow/go-micro-services  > $ make -s
compiled: proto/auth/auth.proto
compiled: proto/geo/geo.proto
compiled: proto/profile/profile.proto
compiled: proto/rate/rate.proto

stalker@zombie ~/workspace/src/github.com/harlow/go-micro-services > $ make build
./build.sh
building cmd/api
building cmd/auth
# github.com/harlow/go-micro-services/cmd/auth
./main.go:37: cannot use md["traceID"] (type []string) as type string in field value
building cmd/geo
# github.com/harlow/go-micro-services/cmd/geo
./main.go:41: cannot use md["traceID"] (type []string) as type string in field value
building cmd/profile
# github.com/harlow/go-micro-services/cmd/profile
./main.go:35: cannot use md["traceID"] (type []string) as type string in field value
building cmd/rate
# github.com/harlow/go-micro-services/cmd/rate
./main.go:41: cannot use md["traceID"] (type []string) as type string in field value

Here is the code of cmd/auth.go:

33 // VerifyToken finds a customer by authentication token.
34 func (s *authServer) VerifyToken(ctx context.Context, args *auth.Args) (*auth.Customer, error) {
35         md, _ := metadata.FromContext(ctx)
36 
37         t := trace.Tracer{TraceID: md["traceID"]}
38         t.In(s.serverName, md["fromName"])
39         defer t.Out(md["fromName"], s.serverName, time.Now())
40 
41         customer := s.customers[args.AuthToken]
42         if customer == nil {
43                 return &auth.Customer{}, errors.New("Invalid Token")
44         }
45 
46         return customer, nil
47 }

The metadata["traceID"], metadata["fromName"] and so on... obviously the []string array, so, it should be fixed? Thanx, Alex!

harlow commented 9 years ago

Looks like there was a breaking change in the gRPC metadata: https://github.com/grpc/grpc-go/commit/484e2d96e586812e3cb446badd27b41d521e9b54#diff-b3a9f1c1b5d5600f4924efe942b13fb0