Class InProcessChannelBuilder
The channel is intended to be fully-featured, high performance, and useful in testing.
For usage examples, see InProcessServerBuilder.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final classCreates InProcess transports.Nested classes/interfaces inherited from class io.grpc.ManagedChannelBuilder
ManagedChannelBuilder.InterceptorFactory -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longprivate final ManagedChannelImplBuilderprivate intprivate ScheduledExecutorServiceprivate boolean -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateInProcessChannelBuilder(SocketAddress directAddress, String target) -
Method Summary
Modifier and TypeMethodDescriptionassumedMessageSize(long assumedMessageSize) Assumes RPC messages are the specified size.(package private) ClientTransportFactoryprotected ManagedChannelBuilder<?> delegate()Returns the delegatedManagedChannelBuilder.static InProcessChannelBuilderforAddress(String name, int port) Always fails.static InProcessChannelBuilderforAddress(SocketAddress address) Create a channel builder that will connect to the server referenced by the given address.static InProcessChannelBuilderCreate a channel builder that will connect to the server with the given name.static InProcessChannelBuilderCreate a channel builder that will connect to the server referenced by the given target URI.keepAliveTime(long keepAliveTime, TimeUnit timeUnit) Does nothing.keepAliveTimeout(long keepAliveTimeout, TimeUnit timeUnit) Does nothing.keepAliveWithoutCalls(boolean enable) Does nothing.maxInboundMessageSize(int max) Sets the maximum message size allowed to be received on the channel.maxInboundMetadataSize(int bytes) Sets the maximum size of metadata allowed to be received.propagateCauseWithStatus(boolean enable) Sets whether to include the cause with the status that is propagated forward from the InProcessTransport.scheduledExecutorService(ScheduledExecutorService scheduledExecutorService) Provides a custom scheduled executor service.(package private) voidsetStatsEnabled(boolean value) Does nothing.Does nothing.Methods inherited from class io.grpc.ForwardingChannelBuilder2
addMetricSink, addTransportFilter, build, compressorRegistry, decompressorRegistry, defaultLoadBalancingPolicy, defaultServiceConfig, directExecutor, disableRetry, disableServiceConfigLookUp, enableRetry, executor, idleTimeout, intercept, intercept, interceptWithTarget, maxHedgedAttempts, maxRetryAttempts, maxTraceEvents, nameResolverFactory, offloadExecutor, overrideAuthority, perRpcBufferLimit, proxyDetector, retryBufferSize, setBinaryLog, toString, userAgent
-
Field Details
-
managedChannelImplBuilder
-
scheduledExecutorService
-
maxInboundMetadataSize
private int maxInboundMetadataSize -
transportIncludeStatusCause
private boolean transportIncludeStatusCause -
assumedMessageSize
private long assumedMessageSize
-
-
Constructor Details
-
InProcessChannelBuilder
-
-
Method Details
-
forName
Create a channel builder that will connect to the server with the given name.- Parameters:
name- the identity of the server to connect to- Returns:
- a new builder
-
forTarget
Create a channel builder that will connect to the server referenced by the given target URI. Only intended for use with a custom name resolver.- Parameters:
target- the identity of the server to connect to- Returns:
- a new builder
-
forAddress
Create a channel builder that will connect to the server referenced by the given address.- Parameters:
address- the address of the server to connect to- Returns:
- a new builder
-
forAddress
Always fails. CallforName(java.lang.String)instead. -
delegate
Description copied from class:ForwardingChannelBuilder2Returns the delegatedManagedChannelBuilder.- Specified by:
delegatein classForwardingChannelBuilder2<InProcessChannelBuilder>
-
maxInboundMessageSize
Description copied from class:ManagedChannelBuilderSets the maximum message size allowed to be received on the channel. If not called, defaults to 4 MiB. The default provides protection to clients who haven't considered the possibility of receiving large messages while trying to be large enough to not be hit in normal usage.This method is advisory, and implementations may decide to not enforce this. Currently, the only known transport to not enforce this is
InProcessTransport.- Overrides:
maxInboundMessageSizein classForwardingChannelBuilder2<InProcessChannelBuilder>- Parameters:
max- the maximum number of bytes a single message can be.- Returns:
- this
-
useTransportSecurity
Does nothing.- Overrides:
useTransportSecurityin classForwardingChannelBuilder2<InProcessChannelBuilder>- Returns:
- this
-
usePlaintext
Does nothing.- Overrides:
usePlaintextin classForwardingChannelBuilder2<InProcessChannelBuilder>- Returns:
- this
-
keepAliveTime
Does nothing.- Overrides:
keepAliveTimein classForwardingChannelBuilder2<InProcessChannelBuilder>- See Also:
-
keepAliveTimeout
Does nothing.- Overrides:
keepAliveTimeoutin classForwardingChannelBuilder2<InProcessChannelBuilder>- See Also:
-
keepAliveWithoutCalls
Does nothing.- Overrides:
keepAliveWithoutCallsin classForwardingChannelBuilder2<InProcessChannelBuilder>- See Also:
-
scheduledExecutorService
public InProcessChannelBuilder scheduledExecutorService(ScheduledExecutorService scheduledExecutorService) Provides a custom scheduled executor service.It's an optional parameter. If the user has not provided a scheduled executor service when the channel is built, the builder will use a static cached thread pool.
- Returns:
- this
- Since:
- 1.11.0
-
maxInboundMetadataSize
Sets the maximum size of metadata allowed to be received.Integer.MAX_VALUEdisables the enforcement. Defaults to no limit (Integer.MAX_VALUE).There is potential for performance penalty when this setting is enabled, as the Metadata must actually be serialized. Since the current implementation of Metadata pre-serializes, it's currently negligible. But Metadata is free to change its implementation.
- Overrides:
maxInboundMetadataSizein classForwardingChannelBuilder2<InProcessChannelBuilder>- Parameters:
bytes- the maximum size of received metadata- Returns:
- this
- Throws:
IllegalArgumentException- if bytes is non-positive- Since:
- 1.17.0
-
propagateCauseWithStatus
Sets whether to include the cause with the status that is propagated forward from the InProcessTransport. This was added to make debugging failing tests easier by showing the cause of the status.By default, this is set to false. A default value of false maintains consistency with other transports which strip causal information from the status to avoid leaking information to untrusted clients, and to avoid sharing language-specific information with the client. For the in-process implementation, this is not a concern.
- Parameters:
enable- whether to include cause in status- Returns:
- this
-
assumedMessageSize
Assumes RPC messages are the specified size. This avoids serializing messages for metrics and retry memory tracking. This can dramatically improve performance when accurate message sizes are not needed and if nothing else needs the serialized message.- Parameters:
assumedMessageSize- length of InProcess transport's messageSize.- Returns:
- this
- Throws:
IllegalArgumentException- if assumedMessageSize is negative.
-
buildTransportFactory
ClientTransportFactory buildTransportFactory() -
setStatsEnabled
void setStatsEnabled(boolean value)
-