Interface TransportChannelProvider
-
- All Known Implementing Classes:
FixedTransportChannelProvider
@InternalExtensionOnly public interface TransportChannelProviderProvides an interface to either build a TransportChannel or provide a fixed TransportChannel that will be used to make calls to a service.Implementations of
TransportChannelProvidermay choose to create a newTransportChannelfor each call togetTransportChannel(), or may return a fixedTransportChannelinstance.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
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description booleanacceptsPoolSize()Deprecated.Pool settings should be configured on the builder of the specific implementation.TransportChannelgetTransportChannel()Provides a Transport, which could either be a new instance for every call, or the same instance, depending on the implementation.java.lang.StringgetTransportName()The name of the transport.booleanneedsCredentials()True if credentials are needed before channel creation.booleanneedsEndpoint()True if the TransportProvider has no endpoint set.booleanneedsExecutor()Deprecated.Channel providers will have default executors if they need one.booleanneedsHeaders()True if the TransportProvider has no headers provided.booleanshouldAutoClose()Indicates whether the TransportChannel should be closed by the containing client class.TransportChannelProviderwithCredentials(com.google.auth.Credentials credentials)Sets the credentials that will be applied before channel creation.TransportChannelProviderwithEndpoint(java.lang.String endpoint)Sets the endpoint to use when constructing a newTransportChannel.TransportChannelProviderwithExecutor(java.util.concurrent.Executor executor)Sets the executor to use when constructing a newTransportChannel.TransportChannelProviderwithExecutor(java.util.concurrent.ScheduledExecutorService executor)Deprecated.Please usewithExecutor(Executor).TransportChannelProviderwithHeaders(java.util.Map<java.lang.String,java.lang.String> headers)Sets the headers to use when constructing a newTransportChannel.TransportChannelProviderwithPoolSize(int size)Deprecated.Pool settings should be configured on the builder of the specific implementation.
-
-
-
Method Detail
-
shouldAutoClose
boolean shouldAutoClose()
Indicates whether the TransportChannel should be closed by the containing client class.
-
needsExecutor
@Deprecated boolean needsExecutor()
Deprecated.Channel providers will have default executors if they need one.True if the TransportProvider needs an executor.
-
withExecutor
TransportChannelProvider withExecutor(java.util.concurrent.Executor executor)
Sets the executor to use when constructing a newTransportChannel.
-
withExecutor
@Deprecated TransportChannelProvider withExecutor(java.util.concurrent.ScheduledExecutorService executor)
Deprecated.Please usewithExecutor(Executor).
-
needsHeaders
boolean needsHeaders()
True if the TransportProvider has no headers provided.
-
withHeaders
TransportChannelProvider withHeaders(java.util.Map<java.lang.String,java.lang.String> headers)
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
TransportChannelProvider withEndpoint(java.lang.String endpoint)
Sets the endpoint to use when constructing a newTransportChannel.This method should only be called if
needsEndpoint()returns true.
-
acceptsPoolSize
@Deprecated boolean acceptsPoolSize()
Deprecated.Pool settings should be configured on the builder of the specific implementation.Reports whether this provider allows pool size customization.
-
withPoolSize
@Deprecated TransportChannelProvider withPoolSize(int size)
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
TransportChannel getTransportChannel() throws java.io.IOException
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:
java.io.IOException
-
getTransportName
java.lang.String getTransportName()
The name of the transport.This string can be used for identifying transports for switching logic.
-
-