module Throttled_rate_limiter: sig
.. end
A Throttled_rate_limiter
combines a Token_bucket
and a Throttle
. Unlike a
Token_bucket
jobs cannot consume variable numbers of tokens, but the number
of outstanding jobs is also limited to max_concurrent_jobs
. Like a Throttle
finish_job
must be called once, and only once when a job is completed.
type
t = private Limiter.limiter
val create_exn : now:Time.t ->
burst_size:int ->
sustained_rate_per_sec:float ->
max_concurrent_jobs:int -> t
val try_start_job : t ->
now:Time.t ->
[ `Max_concurrent_jobs_running | `Start | `Unable_until_at_least of Time.t ]
val finish_job : t -> now:Time.t -> unit