RateLimiter

abstract class RateLimiter

Abstract base class to rate limit IO. Typically implementations are shared across multiple IndexInputs or IndexOutputs (for example those involved all merging). Those IndexInputs and IndexOutputs would call .pause whenever the have read or written more than .getMinPauseCheckBytes bytes.

Inheritors

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard

Simple class to rate limit IO.

Properties

Link copied to clipboard
abstract var mBPerSec: Double

Sets an updated MB per second rate limit. A subclass is allowed to perform dynamic updates of the rate limit during use.

Link copied to clipboard
abstract val minPauseCheckBytes: Long

How many bytes caller should add up itself before invoking .pause. NOTE: The value returned by this method may change over time and is not guaranteed to be constant throughout the lifetime of the RateLimiter. Users are advised to refresh their local values with calls to this method to ensure consistency.

Functions

Link copied to clipboard
abstract suspend fun pause(bytes: Long): Long

Pauses, if necessary, to keep the instantaneous IO rate at or below the target.