Class ThrottledInputStream.Builder

    • Method Detail

      • 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
      • 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.