Sampler

interface Sampler

A Sampler is used to "sample" whether an action is allowed to occur or not.

A common usage of the sampler would look like:

if (sampler.sample()) {
performAction()
}

The frequency at which sample returns true or false is based on the implementation's policy. For example, Sampler.always creates a Sampler that only returns true, while Sampler.percentage will only return true for a given percentage of samples. For a more complex example, Sampler.rateLimiting will limit the number of true samples to a given rate per second.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract fun sample(): Boolean

Tests if a sample is allowed or not

Inheritors

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard