Class InProcessChannelBuilder
- java.lang.Object
-
- io.grpc.ManagedChannelBuilder<T>
-
- io.grpc.ForwardingChannelBuilder2<InProcessChannelBuilder>
-
- io.grpc.inprocess.InProcessChannelBuilder
-
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1783") public final class InProcessChannelBuilder extends ForwardingChannelBuilder2<InProcessChannelBuilder>
Builder for a channel that issues in-process requests. Clients identify the in-process server by its name.The channel is intended to be fully-featured, high performance, and useful in testing.
For usage examples, see
InProcessServerBuilder
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.grpc.ManagedChannelBuilder
ManagedChannelBuilder.InterceptorFactory
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description InProcessChannelBuilder
assumedMessageSize(long assumedMessageSize)
Assumes RPC messages are the specified size.protected ManagedChannelBuilder<?>
delegate()
Returns the delegatedManagedChannelBuilder
.static InProcessChannelBuilder
forAddress(String name, int port)
Always fails.static InProcessChannelBuilder
forAddress(SocketAddress address)
Create a channel builder that will connect to the server referenced by the given address.static InProcessChannelBuilder
forName(String name)
Create a channel builder that will connect to the server with the given name.static InProcessChannelBuilder
forTarget(String target)
Create a channel builder that will connect to the server referenced by the given target URI.InProcessChannelBuilder
keepAliveTime(long keepAliveTime, TimeUnit timeUnit)
Does nothing.InProcessChannelBuilder
keepAliveTimeout(long keepAliveTimeout, TimeUnit timeUnit)
Does nothing.InProcessChannelBuilder
keepAliveWithoutCalls(boolean enable)
Does nothing.InProcessChannelBuilder
maxInboundMessageSize(int max)
Sets the maximum message size allowed to be received on the channel.InProcessChannelBuilder
maxInboundMetadataSize(int bytes)
Sets the maximum size of metadata allowed to be received.InProcessChannelBuilder
propagateCauseWithStatus(boolean enable)
Sets whether to include the cause with the status that is propagated forward from the InProcessTransport.InProcessChannelBuilder
scheduledExecutorService(ScheduledExecutorService scheduledExecutorService)
Provides a custom scheduled executor service.InProcessChannelBuilder
usePlaintext()
Does nothing.InProcessChannelBuilder
useTransportSecurity()
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
-
-
-
-
Method Detail
-
forName
public static InProcessChannelBuilder forName(String name)
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
public static InProcessChannelBuilder forTarget(String target)
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
public static InProcessChannelBuilder forAddress(SocketAddress address)
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
public static InProcessChannelBuilder forAddress(String name, int port)
Always fails. CallforName(java.lang.String)
instead.
-
delegate
@Internal protected ManagedChannelBuilder<?> delegate()
Description copied from class:ForwardingChannelBuilder2
Returns the delegatedManagedChannelBuilder
.- Specified by:
delegate
in classForwardingChannelBuilder2<InProcessChannelBuilder>
-
maxInboundMessageSize
public InProcessChannelBuilder maxInboundMessageSize(int max)
Description copied from class:ManagedChannelBuilder
Sets 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:
maxInboundMessageSize
in classForwardingChannelBuilder2<InProcessChannelBuilder>
- Parameters:
max
- the maximum number of bytes a single message can be.- Returns:
- this
-
useTransportSecurity
public InProcessChannelBuilder useTransportSecurity()
Does nothing.- Overrides:
useTransportSecurity
in classForwardingChannelBuilder2<InProcessChannelBuilder>
- Returns:
- this
-
usePlaintext
public InProcessChannelBuilder usePlaintext()
Does nothing.- Overrides:
usePlaintext
in classForwardingChannelBuilder2<InProcessChannelBuilder>
- Returns:
- this
-
keepAliveTime
public InProcessChannelBuilder keepAliveTime(long keepAliveTime, TimeUnit timeUnit)
Does nothing.- Overrides:
keepAliveTime
in classForwardingChannelBuilder2<InProcessChannelBuilder>
- See Also:
- gRFC A8 Client-side Keepalive
-
keepAliveTimeout
public InProcessChannelBuilder keepAliveTimeout(long keepAliveTimeout, TimeUnit timeUnit)
Does nothing.- Overrides:
keepAliveTimeout
in classForwardingChannelBuilder2<InProcessChannelBuilder>
- See Also:
- gRFC A8 Client-side Keepalive
-
keepAliveWithoutCalls
public InProcessChannelBuilder keepAliveWithoutCalls(boolean enable)
Does nothing.
-
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
public InProcessChannelBuilder maxInboundMetadataSize(int bytes)
Sets the maximum size of metadata allowed to be received.Integer.MAX_VALUE
disables 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:
maxInboundMetadataSize
in classForwardingChannelBuilder2<InProcessChannelBuilder>
- Parameters:
bytes
- the maximum size of received metadata- Returns:
- this
- Throws:
IllegalArgumentException
- if bytes is non-positive- Since:
- 1.17.0
-
propagateCauseWithStatus
public InProcessChannelBuilder propagateCauseWithStatus(boolean enable)
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
public InProcessChannelBuilder assumedMessageSize(long 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.
-
-