Class ThrottledInputStream.Builder

    • Field Detail

      • maxBytesPerSecond

        private double maxBytesPerSecond
        Effectively not throttled.
    • Method Detail

      • getMaxBytesPerSecond

        double getMaxBytesPerSecond()
      • setMaxBytes

        public ThrottledInputStream.Builder setMaxBytes​(long value,
                                                        java.time.temporal.ChronoUnit chronoUnit)
        Sets the maximum bytes per time period unit.

        For example, to throttle reading to 100K per second, use:

         builder.setMaxBytes(100_000, ChronoUnit.SECONDS)
         

        To test idle timeouts for example, use 1 byte per minute, 1 byte per 30 seconds, and so on.

        Parameters:
        value - the maximum bytes
        chronoUnit - a duration scale goal.
        Returns:
        this instance.
        Throws:
        java.lang.IllegalArgumentException - Thrown if maxBytesPerSecond <= 0.
        Since:
        2.19.0
      • setMaxBytes

        ThrottledInputStream.Builder setMaxBytes​(long value,
                                                 java.time.Duration duration)
        Sets the maximum bytes per duration.

        For example, to throttle reading to 100K per second, use:

         builder.setMaxBytes(100_000, Duration.ofSeconds(1))
         

        To test idle timeouts for example, use 1 byte per minute, 1 byte per 30 seconds, and so on.

        Parameters:
        value - the maximum bytes
        duration - a duration goal.
        Returns:
        this instance.
        Throws:
        java.lang.IllegalArgumentException - Thrown if maxBytesPerSecond <= 0.
      • setMaxBytesPerSecond

        private ThrottledInputStream.Builder setMaxBytesPerSecond​(double maxBytesPerSecond)
        Sets the maximum bytes per second.
        Parameters:
        maxBytesPerSecond - the maximum bytes per second.
        Returns:
        this instance.
        Throws:
        java.lang.IllegalArgumentException - Thrown if maxBytesPerSecond <= 0.
      • setMaxBytesPerSecond

        public void setMaxBytesPerSecond​(long maxBytesPerSecond)
        Sets the maximum bytes per second.
        Parameters:
        maxBytesPerSecond - the maximum bytes per second.
        Throws:
        java.lang.IllegalArgumentException - Thrown if maxBytesPerSecond <= 0.