Class Interceptor (2.48.0)

public abstract class Interceptor : object

Serves as the base class for gRPC interceptors.

Inheritance

Object > Interceptor

Namespace

Grpc.Core.Interceptors

Assembly

Grpc.Core.Api.dll

Methods

AsyncClientStreamingCall<TRequest, TResponse>(ClientInterceptorContext<TRequest, TResponse>, Interceptor.AsyncClientStreamingCallContinuation<TRequest, TResponse>)

public virtual AsyncClientStreamingCall<TRequest, TResponse> AsyncClientStreamingCall<TRequest, TResponse>(ClientInterceptorContext<TRequest, TResponse> context, Interceptor.AsyncClientStreamingCallContinuation<TRequest, TResponse> continuation)
    where TRequest : class where TResponse : class

Intercepts an asynchronous invocation of a client streaming call.

Parameters
NameDescription
contextClientInterceptorContext<TRequest, TResponse>

The ClientInterceptorContext<TRequest, TResponse> associated with the current invocation.

continuationInterceptor.AsyncClientStreamingCallContinuation<TRequest, TResponse>

The callback that continues the invocation process. This can be invoked zero or more times by the interceptor. The interceptor can invoke the continuation passing the given context argument, or substitute as it sees fit.

Returns
TypeDescription
AsyncClientStreamingCall<TRequest, TResponse>

An instance of AsyncClientStreamingCall<TRequest, TResponse> representing an asynchronous client-streaming invocation. The interceptor can simply return the return value of the continuation delegate passed to it intact, or construct its own substitute as it sees fit.

Type Parameters
NameDescription
TRequest
TResponse

AsyncDuplexStreamingCall<TRequest, TResponse>(ClientInterceptorContext<TRequest, TResponse>, Interceptor.AsyncDuplexStreamingCallContinuation<TRequest, TResponse>)

public virtual AsyncDuplexStreamingCall<TRequest, TResponse> AsyncDuplexStreamingCall<TRequest, TResponse>(ClientInterceptorContext<TRequest, TResponse> context, Interceptor.AsyncDuplexStreamingCallContinuation<TRequest, TResponse> continuation)
    where TRequest : class where TResponse : class

Intercepts an asynchronous invocation of a duplex streaming call.

Parameters
NameDescription
contextClientInterceptorContext<TRequest, TResponse>

The ClientInterceptorContext<TRequest, TResponse> associated with the current invocation.

continuationInterceptor.AsyncDuplexStreamingCallContinuation<TRequest, TResponse>

The callback that continues the invocation process. This can be invoked zero or more times by the interceptor. The interceptor can invoke the continuation passing the given context argument, or substitute as it sees fit.

Returns
TypeDescription
AsyncDuplexStreamingCall<TRequest, TResponse>

An instance of AsyncDuplexStreamingCall<TRequest, TResponse> representing an asynchronous duplex-streaming invocation. The interceptor can simply return the return value of the continuation delegate passed to it intact, or construct its own substitute as it sees fit.

Type Parameters
NameDescription
TRequest
TResponse

AsyncServerStreamingCall<TRequest, TResponse>(TRequest, ClientInterceptorContext<TRequest, TResponse>, Interceptor.AsyncServerStreamingCallContinuation<TRequest, TResponse>)

public virtual AsyncServerStreamingCall<TResponse> AsyncServerStreamingCall<TRequest, TResponse>(TRequest request, ClientInterceptorContext<TRequest, TResponse> context, Interceptor.AsyncServerStreamingCallContinuation<TRequest, TResponse> continuation)
    where TRequest : class where TResponse : class

Intercepts an asynchronous invocation of a streaming remote call.

Parameters
NameDescription
requestTRequest

The request message of the invocation.

contextClientInterceptorContext<TRequest, TResponse>

The ClientInterceptorContext<TRequest, TResponse> associated with the current invocation.

continuationInterceptor.AsyncServerStreamingCallContinuation<TRequest, TResponse>

The callback that continues the invocation process. This can be invoked zero or more times by the interceptor. The interceptor can invoke the continuation passing the given request value and context arguments, or substitute them as it sees fit.

Returns
TypeDescription
AsyncServerStreamingCall<TResponse>

An instance of AsyncServerStreamingCall<TResponse> representing an asynchronous server-streaming invocation. The interceptor can simply return the return value of the continuation delegate passed to it intact, or construct its own substitute as it sees fit.

Type Parameters
NameDescription
TRequest
TResponse

AsyncUnaryCall<TRequest, TResponse>(TRequest, ClientInterceptorContext<TRequest, TResponse>, Interceptor.AsyncUnaryCallContinuation<TRequest, TResponse>)

public virtual AsyncUnaryCall<TResponse> AsyncUnaryCall<TRequest, TResponse>(TRequest request, ClientInterceptorContext<TRequest, TResponse> context, Interceptor.AsyncUnaryCallContinuation<TRequest, TResponse> continuation)
    where TRequest : class where TResponse : class

Intercepts an asynchronous invocation of a simple remote call.

Parameters
NameDescription
requestTRequest

The request message of the invocation.

contextClientInterceptorContext<TRequest, TResponse>

The ClientInterceptorContext<TRequest, TResponse> associated with the current invocation.

continuationInterceptor.AsyncUnaryCallContinuation<TRequest, TResponse>

The callback that continues the invocation process. This can be invoked zero or more times by the interceptor. The interceptor can invoke the continuation passing the given request value and context arguments, or substitute them as it sees fit.

Returns
TypeDescription
AsyncUnaryCall<TResponse>

An instance of AsyncUnaryCall<TResponse> representing an asynchronous unary invocation. The interceptor can simply return the return value of the continuation delegate passed to it intact, or construct its own substitute as it sees fit.

Type Parameters
NameDescription
TRequest
TResponse

BlockingUnaryCall<TRequest, TResponse>(TRequest, ClientInterceptorContext<TRequest, TResponse>, Interceptor.BlockingUnaryCallContinuation<TRequest, TResponse>)

public virtual TResponse BlockingUnaryCall<TRequest, TResponse>(TRequest request, ClientInterceptorContext<TRequest, TResponse> context, Interceptor.BlockingUnaryCallContinuation<TRequest, TResponse> continuation)
    where TRequest : class where TResponse : class

Intercepts a blocking invocation of a simple remote call.

Parameters
NameDescription
requestTRequest

The request message of the invocation.

contextClientInterceptorContext<TRequest, TResponse>

The ClientInterceptorContext<TRequest, TResponse> associated with the current invocation.

continuationInterceptor.BlockingUnaryCallContinuation<TRequest, TResponse>

The callback that continues the invocation process. This can be invoked zero or more times by the interceptor. The interceptor can invoke the continuation passing the given request value and context arguments, or substitute them as it sees fit.

Returns
TypeDescription
TResponse

The response message of the current invocation. The interceptor can simply return the return value of the continuation delegate passed to it intact, or an arbitrary value as it sees fit.

Type Parameters
NameDescription
TRequest
TResponse

ClientStreamingServerHandler<TRequest, TResponse>(IAsyncStreamReader<TRequest>, ServerCallContext, ClientStreamingServerMethod<TRequest, TResponse>)

public virtual Task<TResponse> ClientStreamingServerHandler<TRequest, TResponse>(IAsyncStreamReader<TRequest> requestStream, ServerCallContext context, ClientStreamingServerMethod<TRequest, TResponse> continuation)
    where TRequest : class where TResponse : class

Server-side handler for intercepting client streaming call.

Parameters
NameDescription
requestStreamIAsyncStreamReader<TRequest>

The request stream of the incoming invocation.

contextServerCallContext

An instance of ServerCallContext representing the context of the invocation.

continuationClientStreamingServerMethod<TRequest, TResponse>

A delegate that asynchronously proceeds with the invocation, calling the next interceptor in the chain, or the service request handler, in case of the last interceptor and return the response value of the RPC. The interceptor can choose to call it zero or more times at its discretion.

Returns
TypeDescription
Task<TResponse>

A future representing the response value of the RPC. The interceptor can simply return the return value from the continuation intact, or an arbitrary response value as it sees fit. The interceptor has the ability to wrap or substitute the request stream when calling the continuation.

Type Parameters
NameDescription
TRequest

Request message type for this method.

TResponse

Response message type for this method.

DuplexStreamingServerHandler<TRequest, TResponse>(IAsyncStreamReader<TRequest>, IServerStreamWriter<TResponse>, ServerCallContext, DuplexStreamingServerMethod<TRequest, TResponse>)

public virtual Task DuplexStreamingServerHandler<TRequest, TResponse>(IAsyncStreamReader<TRequest> requestStream, IServerStreamWriter<TResponse> responseStream, ServerCallContext context, DuplexStreamingServerMethod<TRequest, TResponse> continuation)
    where TRequest : class where TResponse : class

Server-side handler for intercepting bidirectional streaming calls.

Parameters
NameDescription
requestStreamIAsyncStreamReader<TRequest>

The request stream of the incoming invocation.

responseStreamIServerStreamWriter<TResponse>

The response stream of the incoming invocation.

contextServerCallContext

An instance of ServerCallContext representing the context of the invocation.

continuationDuplexStreamingServerMethod<TRequest, TResponse>

A delegate that asynchronously proceeds with the invocation, calling the next interceptor in the chain, or the service request handler, in case of the last interceptor and the interceptor can choose to call it zero or more times at its discretion. The interceptor has the ability to wrap or substitute the request and response streams when calling the continuation.

Returns
TypeDescription
Task
Type Parameters
NameDescription
TRequest

Request message type for this method.

TResponse

Response message type for this method.

ServerStreamingServerHandler<TRequest, TResponse>(TRequest, IServerStreamWriter<TResponse>, ServerCallContext, ServerStreamingServerMethod<TRequest, TResponse>)

public virtual Task ServerStreamingServerHandler<TRequest, TResponse>(TRequest request, IServerStreamWriter<TResponse> responseStream, ServerCallContext context, ServerStreamingServerMethod<TRequest, TResponse> continuation)
    where TRequest : class where TResponse : class

Server-side handler for intercepting server streaming call.

Parameters
NameDescription
requestTRequest

The request value of the incoming invocation.

responseStreamIServerStreamWriter<TResponse>

The response stream of the incoming invocation.

contextServerCallContext

An instance of ServerCallContext representing the context of the invocation.

continuationServerStreamingServerMethod<TRequest, TResponse>

A delegate that asynchronously proceeds with the invocation, calling the next interceptor in the chain, or the service request handler, in case of the last interceptor and the interceptor can choose to call it zero or more times at its discretion. The interceptor has the ability to wrap or substitute the request value and the response stream when calling the continuation.

Returns
TypeDescription
Task
Type Parameters
NameDescription
TRequest

Request message type for this method.

TResponse

Response message type for this method.

UnaryServerHandler<TRequest, TResponse>(TRequest, ServerCallContext, UnaryServerMethod<TRequest, TResponse>)

public virtual Task<TResponse> UnaryServerHandler<TRequest, TResponse>(TRequest request, ServerCallContext context, UnaryServerMethod<TRequest, TResponse> continuation)
    where TRequest : class where TResponse : class

Server-side handler for intercepting and incoming unary call.

Parameters
NameDescription
requestTRequest

The request value of the incoming invocation.

contextServerCallContext

An instance of ServerCallContext representing the context of the invocation.

continuationUnaryServerMethod<TRequest, TResponse>

A delegate that asynchronously proceeds with the invocation, calling the next interceptor in the chain, or the service request handler, in case of the last interceptor and return the response value of the RPC. The interceptor can choose to call it zero or more times at its discretion.

Returns
TypeDescription
Task<TResponse>

A future representing the response value of the RPC. The interceptor can simply return the return value from the continuation intact, or an arbitrary response value as it sees fit.

Type Parameters
NameDescription
TRequest

Request message type for this method.

TResponse

Response message type for this method.