Interface TransportChannelProvider
- All Known Implementing Classes:
FixedTransportChannelProvider
Implementations of TransportChannelProvider may choose to create a new TransportChannel for each call to getTransportChannel(), or may return a fixed TransportChannel instance.
Callers should use the following pattern to get a channel:
TransportChannelProvider transportChannelProvider = ...;
if (transportChannelProvider.needsHeaders()) {
transportChannelProvider = transportChannelProvider.withHeaders(headers);
}
// optional: set executor for TransportChannel
transportChannelProvider.withExecutor(executor);
TransportChannel transportChannel = transportChannelProvider.getTransportChannel();
-
Method Summary
Modifier and TypeMethodDescriptionbooleanDeprecated.Pool settings should be configured on the builder of the specific implementation.default StringUser set custom endpoint for the Transport Channel ProviderProvides a Transport, which could either be a new instance for every call, or the same instance, depending on the implementation.The name of the transport.booleanTrue if credentials are needed before channel creation.booleanTrue if the TransportProvider has no endpoint set.booleanDeprecated.Channel providers will have default executors if they need one.booleanTrue if the TransportProvider has no headers provided.booleanIndicates whether the TransportChannel should be closed by the containing client class.withCredentials(com.google.auth.Credentials credentials) Sets the credentials that will be applied before channel creation.withEndpoint(String endpoint) Sets the endpoint to use when constructing a newTransportChannel.withExecutor(Executor executor) Sets the executor to use when constructing a newTransportChannel.withExecutor(ScheduledExecutorService executor) Deprecated.Please usewithExecutor(Executor).withHeaders(Map<String, String> headers) Sets the headers to use when constructing a newTransportChannel.withPoolSize(int size) Deprecated.Pool settings should be configured on the builder of the specific implementation.default TransportChannelProviderwithUseS2A(boolean useS2A) Sets whether to use S2A when constructing a newTransportChannel.
-
Method Details
-
shouldAutoClose
boolean shouldAutoClose()Indicates whether the TransportChannel should be closed by the containing client class. -
needsExecutor
Deprecated.Channel providers will have default executors if they need one.True if the TransportProvider needs an executor. -
withExecutor
Sets the executor to use when constructing a newTransportChannel. -
withExecutor
Deprecated.Please usewithExecutor(Executor). -
needsHeaders
boolean needsHeaders()True if the TransportProvider has no headers provided. -
withHeaders
Sets the headers to use when constructing a newTransportChannel.This method should only be called if
needsHeaders()returns true. -
needsEndpoint
boolean needsEndpoint()True if the TransportProvider has no endpoint set. -
withEndpoint
Sets the endpoint to use when constructing a newTransportChannel.This method should only be called if
needsEndpoint()returns true. -
withUseS2A
Sets whether to use S2A when constructing a newTransportChannel. -
acceptsPoolSize
Deprecated.Pool settings should be configured on the builder of the specific implementation.Reports whether this provider allows pool size customization. -
withPoolSize
Deprecated.Pool settings should be configured on the builder of the specific implementation.Number of underlying transport channels to open. Calls will be load balanced across them. -
needsCredentials
@BetaApi("The surface to customize credentials is not stable yet and may change in the future.") boolean needsCredentials()True if credentials are needed before channel creation. -
withCredentials
@BetaApi("The surface to customize credentials is not stable yet and may change in the future.") TransportChannelProvider withCredentials(com.google.auth.Credentials credentials) Sets the credentials that will be applied before channel creation. -
getTransportChannel
Provides a Transport, which could either be a new instance for every call, or the same instance, depending on the implementation.If
needsExecutor()is true, thenwithExecutor(Executor)needs to be called first to provide an executor.If
needsHeaders()is true, thenwithHeaders(Map)needs to be called first to provide headers.if
needsEndpoint()is true, thenwithEndpoint(String)needs to be called first to provide an endpoint.- Throws:
IOException
-
getTransportName
String getTransportName()The name of the transport.This string can be used for identifying transports for switching logic.
-
getEndpoint
User set custom endpoint for the Transport Channel ProviderThis is the unresolved endpoint used by GAPICs
-