Class InProcessChannelBuilder


  • @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1783")
    public final class InProcessChannelBuilder
    extends io.grpc.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.

    • Method Detail

      • forName

        public static InProcessChannelBuilder forName​(java.lang.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​(java.lang.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​(java.net.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
      • delegate

        @Internal
        protected io.grpc.ManagedChannelBuilder<?> delegate()
        Specified by:
        delegate in class io.grpc.ForwardingChannelBuilder2<InProcessChannelBuilder>
      • keepAliveTime

        public InProcessChannelBuilder keepAliveTime​(long keepAliveTime,
                                                     java.util.concurrent.TimeUnit timeUnit)
        Does nothing.
        Overrides:
        keepAliveTime in class io.grpc.ForwardingChannelBuilder2<InProcessChannelBuilder>
      • keepAliveTimeout

        public InProcessChannelBuilder keepAliveTimeout​(long keepAliveTimeout,
                                                        java.util.concurrent.TimeUnit timeUnit)
        Does nothing.
        Overrides:
        keepAliveTimeout in class io.grpc.ForwardingChannelBuilder2<InProcessChannelBuilder>
      • scheduledExecutorService

        public InProcessChannelBuilder scheduledExecutorService​(java.util.concurrent.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 class io.grpc.ForwardingChannelBuilder2<InProcessChannelBuilder>
        Parameters:
        bytes - the maximum size of received metadata
        Returns:
        this
        Throws:
        java.lang.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