def throttle(elements: Int, per: FiniteDuration, maximumBurst: Int, mode: ThrottleMode): Repr[Out]
Does maximumBurst
means the number of elements that can be processed at the same time ?
From the scaladoc:
Throttle implements the token bucket model. There is a bucket with a given token capacity (burst size or maximumBurst). Tokens drops into the bucket at a given rate and can be 'spared' for later use up to bucket capacity to allow some burstiness. Whenever stream wants to send an element, it takes as many tokens from the bucket as number of elements. If there isn't any, throttle waits until the bucket accumulates enough tokens. Bucket is full when stream just materialized and started.
maximumBurst
is the token bucket size in the model described above.
Say we start a throttled stream, and the sink starts demanding elements. The throttle stage will emit maximumBurst
of them before backpressuring (with shaping mode) or failing (with enforcing mode).
So I would say it is the maximum number of elements that can be processed without throttling. Processed "at the same time" is never going to be an exact definition in a stream :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With