Class InstantiatingGrpcChannelProvider (2.49.0)

public final class InstantiatingGrpcChannelProvider implements TransportChannelProvider

InstantiatingGrpcChannelProvider is a TransportChannelProvider which constructs a gRPC ManagedChannel with a number of configured inputs every time getChannel(...) is called. These inputs include a port, a service address, and credentials.

The credentials can either be supplied directly (by providing a FixedCredentialsProvider to Builder.setCredentialsProvider()) or acquired implicitly from Application Default Credentials (by providing a GoogleCredentialsProvider to Builder.setCredentialsProvider()).

The client lib header and generator header values are used to form a value that goes into the http header of requests to the service.

Inheritance

java.lang.Object > InstantiatingGrpcChannelProvider

Static Methods

newBuilder()

public static InstantiatingGrpcChannelProvider.Builder newBuilder()
Returns
Type Description
InstantiatingGrpcChannelProvider.Builder

Methods

acceptsPoolSize() (deprecated)

public boolean acceptsPoolSize()

Deprecated. Please modify pool settings via #toBuilder()

Reports whether this provider allows pool size customization.

Returns
Type Description
boolean

getChannelPoolSettings()

public ChannelPoolSettings getChannelPoolSettings()

The configured channel pool settings used for gRPC's ChannelProvider

Returns
Type Description
ChannelPoolSettings

getEndpoint()

public String getEndpoint()

The endpoint to be used for the channel.

Returns
Type Description
String

getKeepAliveTime()

public Duration getKeepAliveTime()

The time without read activity before sending a keepalive ping.

Returns
Type Description
org.threeten.bp.Duration

getKeepAliveTimeout()

public Duration getKeepAliveTimeout()

The time without read activity after sending a keepalive ping.

Returns
Type Description
org.threeten.bp.Duration

getKeepAliveWithoutCalls()

public Boolean getKeepAliveWithoutCalls()

Whether keepalive will be performed when there are no outstanding RPCs.

Returns
Type Description
Boolean

getMaxInboundMetadataSize()

public Integer getMaxInboundMetadataSize()

The maximum metadata size allowed to be received on the channel.

Returns
Type Description
Integer

getTransportChannel()

public 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 String getTransportName()

The name of the transport.

This string can be used for identifying transports for switching logic.

Returns
Type Description
String

needsCredentials()

public boolean needsCredentials()

True if credentials are needed before channel creation.

Returns
Type Description
boolean

needsEndpoint()

public boolean needsEndpoint()

True if the TransportProvider has no endpoint set.

Returns
Type Description
boolean

needsExecutor() (deprecated)

public boolean needsExecutor()

Deprecated. If executor is not set, this channel provider will create channels with default grpc executor.

True if the TransportProvider needs an executor.

Returns
Type Description
boolean

needsHeaders()

public boolean needsHeaders()

True if the TransportProvider has no headers provided.

Returns
Type Description
boolean

shouldAutoClose()

public boolean shouldAutoClose()

Indicates whether the TransportChannel should be closed by the containing client class.

Returns
Type Description
boolean

toBuilder()

public InstantiatingGrpcChannelProvider.Builder toBuilder()
Returns
Type Description
InstantiatingGrpcChannelProvider.Builder

withCredentials(Credentials credentials)

public 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 TransportChannelProvider withEndpoint(String endpoint)

Specify the endpoint the channel should connect to.

The value of endpoint must be of the form host:port.

Parameter
Name Description
endpoint String

The endpoint to connect to

Returns
Type Description
TransportChannelProvider

A new InstantiatingGrpcChannelProvider with the specified endpoint configured

withExecutor(Executor executor)

public 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 TransportChannelProvider withExecutor(ScheduledExecutorService executor)
Parameter
Name Description
executor ScheduledExecutorService
Returns
Type Description
TransportChannelProvider

withHeaders(Map<String,String> headers)

public 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 TransportChannelProvider withPoolSize(int size)

Deprecated. Please modify pool settings via #toBuilder()

Number of underlying transport channels to open. Calls will be load balanced across them.

Parameter
Name Description
size int
Returns
Type Description
TransportChannelProvider