Closed iqbalaydrus closed 2 years ago
@iqbalaydrus inprocgrpc.Channel
implements both grpc.ServiceRegistrar
and grpc.ClientConnInterface
.
In other words, you can use it directly with the generated stubs, e.g. https://pkg.go.dev/google.golang.org/grpc/examples/helloworld/helloworld#RegisterGreeterServer and https://pkg.go.dev/google.golang.org/grpc/examples/helloworld/helloworld#NewGreeterClient .
@iqbalaydrus inprocgrpc.Channel
is mostly used for:
a) writing test cases b) in the rare case that server needs a gRPC channel to itself
Most servers do not need an inproc channel. Are you trying to solve something specific?
Ok, so I finally got it working. My usecase is we're building an application in a microservices manner via grpc, but can also be deployed only a single process. I was thinking to use inprocgrpc to have better performance compared to using localhost / in-memory transport if the application deployed to a single process. But weirdly it has slightly worse performance than the said alternatives, or maybe it's expected?
I'm closing this issue since the main question is answered.
Interesting! I am surprised that inprocess channel would have worse performance than a literal TCP connection to the same process, but it's not impossible.
@iqbalaydrus can you describe in more detail the performance of inprocgrc?
I've been digging the repo for a few hours and have no idea how to use the package. Also read the docs at https://pkg.go.dev/github.com/fullstorydev/grpchan@v1.1.1/inprocgrpc and still has no clue.
Server: https://github.com/grpc/grpc-go/blob/master/examples/helloworld/greeter_server/main.go
As for the client I absolutely has no clue how to use that. Can you give me an example on how to use inprocgrpc? Or direct me to some docs if available? Thank you