Class CallInvokerExtensions (2.48.0)

public static class CallInvokerExtensions : object

Extends the CallInvoker class to provide the interceptor facility on the client side.

Inheritance

Object > CallInvokerExtensions

Namespace

Grpc.Core.Interceptors

Assembly

Grpc.Core.Api.dll

Methods

Intercept(CallInvoker, Func<Metadata, Metadata>)

public static CallInvoker Intercept(this CallInvoker invoker, Func<Metadata, Metadata> interceptor)

Returns a CallInvoker instance that intercepts the invoker with the given interceptor.

Parameters
Name Description
invoker CallInvoker

The underlying invoker to intercept.

interceptor Func<Metadata, Metadata>

An interceptor delegate that takes the request metadata to be sent with an outgoing call and returns a Metadata instance that will replace the existing invocation metadata.

Returns
Type Description
CallInvoker
Remarks

Multiple interceptors can be added on top of each other by building a chain like "invoker.Intercept(c).Intercept(b).Intercept(a)". Note that in this case, the last interceptor added will be the first to take control.

Intercept(CallInvoker, Interceptor)

public static CallInvoker Intercept(this CallInvoker invoker, Interceptor interceptor)

Returns a CallInvoker instance that intercepts the invoker with the given interceptor.

Parameters
Name Description
invoker CallInvoker

The underlying invoker to intercept.

interceptor Interceptor

The interceptor to intercept calls to the invoker with.

Returns
Type Description
CallInvoker
Remarks

Multiple interceptors can be added on top of each other by calling "invoker.Intercept(a, b, c)". The order of invocation will be "a", "b", and then "c". Interceptors can be later added to an existing intercepted CallInvoker, effectively building a chain like "invoker.Intercept(c).Intercept(b).Intercept(a)". Note that in this case, the last interceptor added will be the first to take control.

Intercept(CallInvoker, Interceptor[])

public static CallInvoker Intercept(this CallInvoker invoker, params Interceptor[] interceptors)

Returns a CallInvoker instance that intercepts the invoker with the given interceptors.

Parameters
Name Description
invoker CallInvoker

The channel to intercept.

interceptors Interceptor[]

An array of interceptors to intercept the calls to the invoker with. Control is passed to the interceptors in the order specified.

Returns
Type Description
CallInvoker
Remarks

Multiple interceptors can be added on top of each other by calling "invoker.Intercept(a, b, c)". The order of invocation will be "a", "b", and then "c". Interceptors can be later added to an existing intercepted CallInvoker, effectively building a chain like "invoker.Intercept(c).Intercept(b).Intercept(a)". Note that in this case, the last interceptor added will be the first to take control.