Class CallCredentials
- java.lang.Object
-
- io.grpc.CallCredentials
-
- Direct Known Subclasses:
CompositeCallCredentials
public abstract class CallCredentials extends Object
Carries credential data that will be propagated to the server via request metadata for each RPC.This is used by
CallOptions.withCallCredentials(io.grpc.CallCredentials)
andwithCallCredentials()
on the generated stub, for example:FooGrpc.FooStub stub = FooGrpc.newStub(channel); response = stub.withCallCredentials(creds).bar(request);
The contents and nature of this class (and whether it remains an abstract class) is experimental, in that it can change. However, we are guaranteeing stability for the name. That is, we are guaranteeing stability for code to be returned a reference and pass that reference to gRPC for usage. However, code may not call or implement the
CallCredentials
itself if it wishes to only use stable APIs.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CallCredentials.MetadataApplier
The outlet of the produced headers.static class
CallCredentials.RequestInfo
The request-related information passed toCallCredentials.applyRequestMetadata()
.
-
Constructor Summary
Constructors Constructor Description CallCredentials()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract void
applyRequestMetadata(CallCredentials.RequestInfo requestInfo, Executor appExecutor, CallCredentials.MetadataApplier applier)
Pass the credential data to the givenCallCredentials.MetadataApplier
, which will propagate it to the request metadata.void
thisUsesUnstableApi()
Deprecated.
-
-
-
Method Detail
-
applyRequestMetadata
public abstract void applyRequestMetadata(CallCredentials.RequestInfo requestInfo, Executor appExecutor, CallCredentials.MetadataApplier applier)
Pass the credential data to the givenCallCredentials.MetadataApplier
, which will propagate it to the request metadata.It is called for each individual RPC, within the
Context
of the call, before the stream is about to be created on a transport. Implementations should not block in this method. If metadata is not immediately available, e.g., needs to be fetched from network, the implementation may give theappExecutor
an asynchronous task which will eventually call theapplier
. The RPC proceeds only after theapplier
is called.- Parameters:
requestInfo
- request-related informationappExecutor
- The application thread-pool. It is provided to the implementation in case it needs to perform blocking operations.applier
- The outlet of the produced headers. It can be called either before or after this method returns.
-
thisUsesUnstableApi
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1914") @Deprecated public void thisUsesUnstableApi()
Deprecated.With this class now being stable this method moves from an abstract one to a normal one with a no-op implementation. This method is marked deprecated to allow extenders time to remove the method before it is removed here.
-
-