Skip to content

Instantly share code, notes, and snippets.

@RicardoLinck
Created June 25, 2020 21:51
Show Gist options
  • Select an option

  • Save RicardoLinck/0b9c77bd52c7d07f3c0c99da6ae18773 to your computer and use it in GitHub Desktop.

Select an option

Save RicardoLinck/0b9c77bd52c7d07f3c0c99da6ae18773 to your computer and use it in GitHub Desktop.
func (*server) Greet(ctx context.Context, req *greetpb.GreetRequest) (*greetpb.GreetResponse, error) {
log.Println("Greet rpc invoked!")
time.Sleep(500 * time.Millisecond)
if ctx.Err() == context.Canceled {
return nil, status.Error(codes.Canceled, "Client cancelled the request")
}
first := req.Greeting.FirstName
return &greetpb.GreetResponse{
Result: fmt.Sprintf("Hello %s", first),
}, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment