Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interceptor support #29

Open
joschmo80 opened this issue Nov 3, 2021 · 4 comments
Open

Interceptor support #29

joschmo80 opened this issue Nov 3, 2021 · 4 comments

Comments

@joschmo80
Copy link

joschmo80 commented Nov 3, 2021

Hello,

I have a .NET 5.0 app that uses gRpc and your package to perform IPC. I wish to add interceptors for global logging, error handling, and profiling. I attempted the solution in https://stackoverflow.com/questions/55630096/grcp-intercept-calls-in-c-sharp, but could not see a way to add the interceptor. That is b/c, per your README, the proper way to bind the service is via:

Greeter.BindService(server.ServiceBinder, new GreeterService());

Which (as best I can tell) does not provide access to the .Intercept API. Any suggestions?

Thanks!

@cyanfish
Copy link
Owner

If you're willing to use some reflection, something like this should work:

var def = Greeter.BindService(new GreeterService());
var def2 = def.Intercept(...); // Needs a Grpc.Core reference
def2.BindService(server.ServiceBinder); // BindService is internal to Grpc.Core.Api so you'll need reflection to do this call

@joschmo80
Copy link
Author

Sorry, just getting around to looking at this now. I now realize that the Intercept API requires Grpc.Core, which will be deprecated per https://grpc.io/blog/grpc-csharp-future/.

Would it be possible to provide an Intercept API that doesn't require reflection or reference to Grpc.Core?

Also, and somewhat related: Can you provide any advice on this package (GrpcNamedPipes) vs. https://docs.microsoft.com/en-us/aspnet/core/grpc/interprocess?view=aspnetcore-6.0 ? I love your library b/c it is easy to setup and use, but am wondering if it is better to go with something officially supported by the gRpc team.

As always, thanks for your help - much appreciated!

@cyanfish
Copy link
Owner

cyanfish commented Feb 7, 2022

Thanks for the link, I didn't realize that had been implemented - Unix domain sockets should be comparable to named pipes, providing you're using Windows 10.

This library will still have advantages in terms of being lightweight (and probably better performance but I'd need to test). But otherwise Kestrel would be a good solution, especially if you need features I haven't implemented.

@NeverMorewd
Copy link
Contributor

Sorry, just getting around to looking at this now. I now realize that the Intercept API requires Grpc.Core, which will be deprecated per https://grpc.io/blog/grpc-csharp-future/.

Would it be possible to provide an Intercept API that doesn't require reflection or reference to Grpc.Core?

Also, and somewhat related: Can you provide any advice on this package (GrpcNamedPipes) vs. https://docs.microsoft.com/en-us/aspnet/core/grpc/interprocess?view=aspnetcore-6.0 ? I love your library b/c it is easy to setup and use, but am wondering if it is better to go with something officially supported by the gRpc team.

As always, thanks for your help - much appreciated!

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants