Class InProcessChannelBuilder

    • Field Detail

      • scheduledExecutorService

        private java.util.concurrent.ScheduledExecutorService scheduledExecutorService
      • maxInboundMetadataSize

        private int maxInboundMetadataSize
      • transportIncludeStatusCause

        private boolean transportIncludeStatusCause
      • assumedMessageSize

        private long assumedMessageSize
    • Constructor Detail

      • InProcessChannelBuilder

        private InProcessChannelBuilder​(@Nullable
                                        java.net.SocketAddress directAddress,
                                        @Nullable
                                        java.lang.String target)
    • 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
      • 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 class ForwardingChannelBuilder2<InProcessChannelBuilder>
        Parameters:
        max - the maximum number of bytes a single message can be.
        Returns:
        this
      • 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 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
      • 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:
        java.lang.IllegalArgumentException - if assumedMessageSize is negative.
      • setStatsEnabled

        void setStatsEnabled​(boolean value)