Created
April 14, 2020 17:45
-
-
Save vivainio/6947d10a4c8cfc56c5d0e4c08c43e1d2 to your computer and use it in GitHub Desktop.
This file contains 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
class SomeGrpcServerInterceptor: Interceptor | |
{ | |
private IWindsorContainer container; | |
public P2PGrpcServerInterceptor(IWindsorContainer container) | |
{ | |
this.container = container; | |
} | |
// xxx override others as well? | |
public override async Task<TResponse> UnaryServerHandler<TRequest, TResponse>(TRequest request, ServerCallContext context, | |
UnaryServerMethod<TRequest, TResponse> continuation) | |
{ | |
try | |
{ | |
using (GrpcCallScope.Begin(context, container)) | |
{ | |
var ret = await base.UnaryServerHandler(request, context, continuation); | |
return ret; | |
} | |
} | |
catch (Exception ex) | |
{ | |
var logger = container.Resolve<ILogger>(); | |
logger.Error($"Error during gRPC call {context.Method} from {context.Peer}", ex); | |
throw; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment