Class GrpcClientOptions


  • public class GrpcClientOptions
    extends Object
    Options configuring a gRPC client.
    • Field Detail

      • DEFAULT_SCHEDULE_DEADLINE_AUTOMATICALLY

        public static final boolean DEFAULT_SCHEDULE_DEADLINE_AUTOMATICALLY
        The default value for automatic deadline schedule = false.
        See Also:
        Constant Field Values
      • DEFAULT_TIMEOUT

        public static final int DEFAULT_TIMEOUT
        The default value of the timeout = 0 (no timeout).
        See Also:
        Constant Field Values
      • DEFAULT_TIMEOUT_UNIT

        public static final TimeUnit DEFAULT_TIMEOUT_UNIT
        The default value of the timeout unit = TimeUnit.SECONDS.
      • DEFAULT_MAX_MESSAGE_SIZE

        public static final long DEFAULT_MAX_MESSAGE_SIZE
        The default maximum message size in bytes accepted from a server = 256KB
        See Also:
        Constant Field Values
    • Constructor Detail

      • GrpcClientOptions

        public GrpcClientOptions()
        Default constructor.
      • GrpcClientOptions

        public GrpcClientOptions​(GrpcClientOptions other)
        Copy constructor.
        Parameters:
        other - the options to copy
    • Method Detail

      • getScheduleDeadlineAutomatically

        public boolean getScheduleDeadlineAutomatically()
        Returns:
        whether the client will automatically schedule a deadline when a request carrying a timeout is sent.
      • setScheduleDeadlineAutomatically

        public GrpcClientOptions setScheduleDeadlineAutomatically​(boolean handleDeadlineAutomatically)

        Set whether a deadline is automatically scheduled when a request carrying a timeout (either set explicitly or through this options instance) is sent.

        • When the automatic deadline is set and a request carrying a timeout is sent, a deadline (timer) is created to cancel the request when the response has not been timely received. The deadline can be obtained with GrpcClientRequest.deadline().
        • When the deadline is not set and a request carrying a timeout is sent, the timeout is sent to the server and it remains the responsibility of the caller to eventually cancel the request. Note: the server might cancel the request as well when its local deadline is met.
        Parameters:
        handleDeadlineAutomatically - whether to automatically set
        Returns:
        a reference to this, so the API can be used fluently
      • getTimeout

        public int getTimeout()
        Return the default timeout set when sending gRPC requests, the initial value is 0 which does not send a timeout.
        Returns:
        the default timeout.
      • setTimeout

        public GrpcClientOptions setTimeout​(int timeout)
        Set the default timeout set when sending gRPC requests, this value should be set along with setTimeoutUnit(TimeUnit).
        Parameters:
        timeout - the timeout value
        Returns:
        a reference to this, so the API can be used fluently
      • getTimeoutUnit

        public TimeUnit getTimeoutUnit()
        Returns:
        the unit of time of the default timeout.
      • setTimeoutUnit

        public GrpcClientOptions setTimeoutUnit​(TimeUnit timeoutUnit)
        Set the unit of time of the default timeout value.
        Parameters:
        timeoutUnit - the unit of time
        Returns:
        a reference to this, so the API can be used fluently
      • getMaxMessageSize

        public long getMaxMessageSize()
        Returns:
        the maximum message size in bytes accepted by the client
      • setMaxMessageSize

        public GrpcClientOptions setMaxMessageSize​(long maxMessageSize)
        Set the maximum message size in bytes accepted from a server, the maximum value is 0xFFFFFFFF
        Parameters:
        maxMessageSize - the size
        Returns:
        a reference to this, so the API can be used fluently