Hi Guys,

I have a grpc service which does some cpu intensive work.
Before starting the work, I want to ensure that the client hasn't cancelled 
this aforementioned work.
Rather than checking in every service, I would like to write an interceptor 
which would check and drop the request if it has been cancelled.

This is what I have come up with but I can't figure out how to drop the 
request and signal to the client.
Any pointers are much appreciated.

Cheers

public final class CancelledRequestInterceptor implements ServerInterceptor{

@Override
public final <R, S> Server.Listener<R> interceptCall( ServerCall<R,S> call, 
Metadata meta, ServerCallHandler<R, S> next ){

    boolean isCancelled = Context.current().isCancelled();
    if( isCancelled ){
       //How do I discard the call and signal to the client that it has 
been discarded
    }else{
       return next.startCall( call, headers );
    }

}



-- 
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/44bd8313-88c9-4758-a007-28be38cc4c25%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to