Top Description Methods
io.grpc

public Interface ClientInterceptor

Annotations
@ThreadSafe
Imports
javax.annotation.concurrent.ThreadSafe

Interface for intercepting outgoing calls before they are dispatched by a Channel.

Implementers use this mechanism to add cross-cutting behavior to Channel and stub implementations. Common examples of such behavior include:

Providing authentication credentials is better served by CallCredentials. But a ClientInterceptor could set the CallCredentials within the CallOptions.

The interceptor may be called for multiple calls by one or more threads without completing the previous ones first. Refer to the ClientCall.Listener docs for more details regarding thread safety of the returned listener.

Method Summary

Modifier and TypeMethod and Description
public <ReqT, RespT> ClientCall<ReqT, RespT>

Returns:

the call object for the remote operation, never null.
interceptCall
(MethodDescriptor<ReqT, RespT>
the remote method to be called.
method
,
CallOptions
the runtime options to be applied to this call.
callOptions
,
Channel
the channel which is being intercepted.
next
)

Intercept ClientCall creation by the next Channel.

Method Detail

interceptCallback to summary
public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, Channel next)

Intercept ClientCall creation by the next Channel.

Many variations of interception are possible. Complex implementations may return a wrapper around the result of next.newCall(), whereas a simpler implementation may just modify the header metadata prior to returning the result of next.newCall().

next.newCall() must not be called under a different Context other than the current Context. The outcome of such usage is undefined and may cause memory leak due to unbounded chain of Contexts.

Parameters
method:MethodDescriptor<ReqT, RespT>

the remote method to be called.

callOptions:CallOptions

the runtime options to be applied to this call.

next:Channel

the channel which is being intercepted.

Returns:ClientCall<ReqT, RespT>

the call object for the remote operation, never null.