0

I want to have an interceptor for grpc in c# .net core to check all request credentials and log all rpc exception but if Continuation method calls without Await key word its exception doesn't throw in this level. so I await for continuation in interceptor to catch all excetions. All things work well so far, but I don't know if it may cause any problem later specially in multiple cincurrent rpc calls?

    public override async Task<TResponse> UnaryServerHandler<TRequest, TResponse>(TRequest request, ServerCallContext context, UnaryServerMethod<TRequest, TResponse> continuation)
    {
        try
        {
            CheckLogin(context);
            var res = await continuation(request, context);        
            return res;
        }
        catch (RpcException ex)
        {
            _logger.LogError(ex, "RPC Error. UnaryServerHanler Error. Method : {method}", context.Method);
            throw ex;
        }
        catch (Exception ex)
        {
            _logger.LogError(ex, "UnaryServerHanler Error. Method : {method}", context.Method);
            throw ex;
        }
    }
ali afshari
  • 62
  • 1
  • 7

1 Answers1

0

You should not worry about using the await keyword while executing async methods.

Actually- this mechanism is built for better handling concurrency code execution.

Please watch https://stackoverflow.com/a/14178317/7779827

DanielFr
  • 111
  • 1
  • 6