def throttle(elements: Int, per: FiniteDuration, maximumBurst: Int, mode: ThrottleMode): Repr[Out]
是否
maximumBurst
意味着可以同时处理的元素数量?
最佳答案
来自 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
是上述模型中的 token 桶大小。假设我们启动了一个节流的流,并且接收器开始要求元素。 throttle 级会发出
maximumBurst
在背压(使用整形模式)或失败(使用强制模式)之前,它们。所以我会说这是可以在不限制的情况下处理的最大元素数。 “同时”处理永远不会是流中的精确定义:)
关于scala - akka 流 throttle 如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44797214/