@InternalExtensionOnly
public interface TransportChannelProvider
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.needsExecutor()) {
transportChannelProvider = transportChannelProvider.withExecutor(executor);
}
if (transportChannelProvider.needsHeaders()) {
transportChannelProvider = transportChannelProvider.withHeaders(headers);
}
TransportChannel transportChannel = transportChannelProvider.getTransportChannel();
| Modifier and Type | Method and Description |
|---|---|
boolean |
acceptsPoolSize()
Reports whether this provider allows pool size customization.
|
TransportChannel |
getTransportChannel()
Provides a Transport, which could either be a new instance for every call, or the same
instance, depending on the implementation.
|
String |
getTransportName()
The name of the transport.
|
boolean |
needsEndpoint()
True if the TransportProvider has no endpoint set.
|
boolean |
needsExecutor()
True if the TransportProvider needs an executor.
|
boolean |
needsHeaders()
True if the TransportProvider has no headers provided.
|
boolean |
shouldAutoClose()
Indicates whether the TransportChannel should be closed by the containing client class.
|
TransportChannelProvider |
withEndpoint(String endpoint)
Sets the endpoint to use when constructing a new
TransportChannel. |
TransportChannelProvider |
withExecutor(ScheduledExecutorService executor)
Sets the executor to use when constructing a new
TransportChannel.. |
TransportChannelProvider |
withHeaders(Map<String,String> headers)
Sets the headers to use when constructing a new
TransportChannel.. |
TransportChannelProvider |
withPoolSize(int size)
Number of underlying transport channels to open.
|
boolean shouldAutoClose()
boolean needsExecutor()
TransportChannelProvider withExecutor(ScheduledExecutorService executor)
TransportChannel..
This method should only be called if needsExecutor() returns true.
@BetaApi(value="The surface for customizing headers is not stable yet and may change in the future.") boolean needsHeaders()
@BetaApi(value="The surface for customizing headers is not stable yet and may change in the future.") TransportChannelProvider withHeaders(Map<String,String> headers)
TransportChannel..
This method should only be called if needsHeaders() returns true.
boolean needsEndpoint()
TransportChannelProvider withEndpoint(String endpoint)
TransportChannel.
This method should only be called if needsEndpoint() returns true.
@BetaApi(value="The surface for customizing pool size is not stable yet and may change in the future.") boolean acceptsPoolSize()
@BetaApi(value="The surface for customizing pool size is not stable yet and may change in the future.") TransportChannelProvider withPoolSize(int size)
TransportChannel getTransportChannel() throws IOException
If needsExecutor() is true, then withExecutor(ScheduledExecutorService)
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.
IOExceptionString getTransportName()
This string can be used for identifying transports for switching logic.