Thanks Jan, I just got to test this out and this is exactly what I was 
after.

On Friday, April 6, 2018 at 9:29:54 AM UTC+1, Jan Tattermusch wrote:
>
> In C# status server handlers (and also in interceptors on the serverside), 
> you can set the resulting status without throwing an exception by setting 
> ServerCallContext's "Status" property.
>
> https://github.com/grpc/grpc/blob/1c73e2c53ddecf3bd45f1c28d23a895fc7cd6e12/src/csharp/Grpc.Core/ServerCallContext.cs#L155
>
> call.Status = new Status(StatusCode.WhateverYouWant, "");
> // and then return from the server side handler.
>
> A test that demonstrates this is here: 
> https://github.com/grpc/grpc/blob/1c73e2c53ddecf3bd45f1c28d23a895fc7cd6e12/src/csharp/Grpc.Core.Tests/ClientServerTest.cs#L129
>
> On Tuesday, April 3, 2018 at 11:25:18 AM UTC+2, Joseph Vaughan wrote:
>>
>> I have a few instances where I'd like my gRPC server to reject an RPC 
>> call using the newly introduced Interceptors functionality. I've read the 
>> documentation and can see that this is a desired piece of functionality 
>> (Cancelling 
>> RPCs <https://grpc.io/docs/guides/concepts.html#cancelling-rpcs>). I can 
>> see the functionality is available within the Java API (ServerCall.java 
>> <https://github.com/grpc/grpc-java/blob/master/core/src/main/java/io/grpc/ServerCall.java#L155>)
>>  
>> which looks perfect for what I'd like to do (Cancel the RPC and return one 
>> of the internal gRPC status codes). The best solution I can find right now 
>> for a C# server is to raise an RpcException with a Status, however I'd like 
>> to avoid the use of exceptions for common control flow where possible. 
>>
>> Ideally I'm looking for the same functionality as demonstrated here: 
>> https://github.com/grpc/grpc-java/issues/779#issuecomment-130365950 
>>
>> Am I missing something on the C# side where I can already do this, and if 
>> not, are there plans to introduce a similar API?
>>
>> Thanks,
>> Joseph.
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/7569fd67-806c-44be-b0e2-6f7522693520%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to