What's interesting to me is that when I create the GRPC client in another package (outside main) and try to use it elsewhere... the GRPC calls fails with:
rpc error: code = Canceled desc = grpc: the client connection is closing
Thanks for the reply. I figured it out. Gotta be careful with defer conn.Close() if calling outside main function... After function ends it will close the connection and the client cannot be used anymore.
What's interesting to me is that when I create the GRPC client in another package (outside main) and try to use it elsewhere... the GRPC calls fails with:
Any thoughts on this peculiarity?
Not sure what happened on your computer, could you provide a sample for reproducing?
Thanks for the reply. I figured it out. Gotta be careful with
defer conn.Close()
if calling outside main function... After function ends it will close the connection and the client cannot be used anymore.Good to hear that; yes, better to using context if you want to manage the lifecycle. It provides a not bad abstraction for stopping a goroutine.