Last active
April 29, 2019 19:46
-
-
Save KamilLelonek/88b8aded9ce84d7a1a50692d7a13b3e7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const port = ":50051" | |
| type gravatarService struct{} | |
| func (s *gravatarService) Generate(ctx context.Context, in *pb.GravatarRequest) (*pb.GravatarResponse, error) { | |
| log.Printf("Received email %v with size %v", in.Email, in.Size) | |
| return &pb.GravatarResponse{Url: gravatar(in.Email, in.Size)}, nil | |
| } | |
| func main() { | |
| lis, err := net.Listen("tcp", port) | |
| if err != nil { | |
| log.Fatalf("Failed to listen on port: %v", err) | |
| } | |
| server := grpc.NewServer() | |
| pb.RegisterGravatarServiceServer(server, &gravatarService{}) | |
| if err := server.Serve(lis); err != nil { | |
| log.Fatal(errors.Wrap(err, "Failed to start server!")) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment