Skip to contents

Create an R6 object for throttling.

Usage

crew_throttle(seconds_interval = 0.5)

Arguments

seconds_interval

Positive numeric of length 1, throttling interval. The poll() method returns TRUE if and only if it was not called in the last seconds_interval seconds.

Value

An R6 object with throttle configuration settings and methods.

Details

Throttling is a technique that limits how often a function is called in a given period of time. crew_throttle() objects support the throttle argument of controller methods, which ensures auto-scaling only happen every seconds_interval seconds. This helps avoid overburdening the mirai dispatcher and other resources.

See also

Other throttle: crew_class_throttle

Examples

throttle <- crew_throttle(seconds_interval = 0.5)
throttle$poll()
#> [1] TRUE
throttle$poll()
#> [1] FALSE