gpt4 book ai didi

scala - akka 流 throttle 如何工作?

转载 作者:行者123 更新时间:2023-12-01 09:40:16 25 4
gpt4 key购买 nike

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com