public interface TransportChannelProvider
Provides an interface to either build a TransportChannel or provide a fixed TransportChannel that will be used to make calls to a service.
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();
Methods
acceptsPoolSize() (deprecated)
public abstract boolean acceptsPoolSize()
Deprecated. Pool settings should be configured on the builder of the specific implementation.
Reports whether this provider allows pool size customization.
Returns | |
---|---|
Type | Description |
boolean |
getEndpoint()
public default String getEndpoint()
User set custom endpoint for the Transport Channel Provider
This is the unresolved endpoint used by GAPICs
Returns | |
---|---|
Type | Description |
String |
getTransportChannel()
public abstract TransportChannel 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, then #withExecutor(Executor) needs to be called first to provide an executor.
If #needsHeaders() is true, then #withHeaders(Map) needs to be called first to provide headers.
if #needsEndpoint() is true, then #withEndpoint(String) needs to be called first to provide an endpoint.
Returns | |
---|---|
Type | Description |
TransportChannel |
Exceptions | |
---|---|
Type | Description |
IOException |
getTransportName()
public abstract String getTransportName()
The name of the transport.
This string can be used for identifying transports for switching logic.
Returns | |
---|---|
Type | Description |
String |
needsCredentials()
public abstract boolean needsCredentials()
True if credentials are needed before channel creation.
Returns | |
---|---|
Type | Description |
boolean |
needsEndpoint()
public abstract boolean needsEndpoint()
True if the TransportProvider has no endpoint set.
Returns | |
---|---|
Type | Description |
boolean |
needsExecutor() (deprecated)
public abstract boolean needsExecutor()
Deprecated. Channel providers will have default executors if they need one.
True if the TransportProvider needs an executor.
Returns | |
---|---|
Type | Description |
boolean |
needsHeaders()
public abstract boolean needsHeaders()
True if the TransportProvider has no headers provided.
Returns | |
---|---|
Type | Description |
boolean |
shouldAutoClose()
public abstract boolean shouldAutoClose()
Indicates whether the TransportChannel should be closed by the containing client class.
Returns | |
---|---|
Type | Description |
boolean |
withCredentials(Credentials credentials)
public abstract TransportChannelProvider withCredentials(Credentials credentials)
Sets the credentials that will be applied before channel creation.
Parameter | |
---|---|
Name | Description |
credentials |
com.google.auth.Credentials |
Returns | |
---|---|
Type | Description |
TransportChannelProvider |
withEndpoint(String endpoint)
public abstract TransportChannelProvider withEndpoint(String endpoint)
Sets the endpoint to use when constructing a new TransportChannel.
This method should only be called if #needsEndpoint() returns true.
Parameter | |
---|---|
Name | Description |
endpoint |
String |
Returns | |
---|---|
Type | Description |
TransportChannelProvider |
withExecutor(Executor executor)
public abstract TransportChannelProvider withExecutor(Executor executor)
Sets the executor to use when constructing a new TransportChannel.
Parameter | |
---|---|
Name | Description |
executor |
Executor |
Returns | |
---|---|
Type | Description |
TransportChannelProvider |
withExecutor(ScheduledExecutorService executor) (deprecated)
public abstract TransportChannelProvider withExecutor(ScheduledExecutorService executor)
Deprecated. Please use #withExecutor(Executor).
Parameter | |
---|---|
Name | Description |
executor |
ScheduledExecutorService |
Returns | |
---|---|
Type | Description |
TransportChannelProvider |
withHeaders(Map<String,String> headers)
public abstract TransportChannelProvider withHeaders(Map<String,String> headers)
Sets the headers to use when constructing a new TransportChannel.
This method should only be called if #needsHeaders() returns true.
Parameter | |
---|---|
Name | Description |
headers |
Map<String,String> |
Returns | |
---|---|
Type | Description |
TransportChannelProvider |
withPoolSize(int size) (deprecated)
public abstract 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.
Parameter | |
---|---|
Name | Description |
size |
int |
Returns | |
---|---|
Type | Description |
TransportChannelProvider |