Cooldown Algorithms API Reference#
- class lightbulb.cooldown_algorithms.BangBangCooldownAlgorithm[source]#
Cooldown algorithm that allows
n
command invocations to be used, and then waits for the appropriate amount of time before allowing any additional invocations.- evaluate(bucket: buckets.Bucket) CooldownStatus [source]#
Evaluate whether the command should be on cooldown given internal state of this object and the bucket object passed in.
- Parameters:
bucket (
Bucket
) – The bucket to process the cooldown for.- Returns:
The status of the cooldown.
- Return type:
- class lightbulb.cooldown_algorithms.CooldownAlgorithm[source]#
Base class that represents an algorithm that can be used to calculate whether a command is on cooldown or not.
- abstract evaluate(bucket: buckets.Bucket) t.Union[CooldownStatus, t.Coroutine[t.Any, t.Any, CooldownStatus]] [source]#
Evaluate whether the command should be on cooldown given internal state of this object and the bucket object passed in.
- Parameters:
bucket (
Bucket
) – The bucket to process the cooldown for.- Returns:
The status of the cooldown.
- Return type:
- class lightbulb.cooldown_algorithms.FixedWindowCooldownAlgorithm[source]#
Cooldown algorithm that allows
n
command invocations within a fixed window time period. I.e. 5 invocations within a 30-second time period, allowing additional invocations once the entire period has elapsed.- evaluate(bucket: buckets.Bucket) CooldownStatus [source]#
Evaluate whether the command should be on cooldown given internal state of this object and the bucket object passed in.
- Parameters:
bucket (
Bucket
) – The bucket to process the cooldown for.- Returns:
The status of the cooldown.
- Return type:
- class lightbulb.cooldown_algorithms.SlidingWindowCooldownAlgorithm[source]#
Cooldown algorithm that allows
n
command invocations within a sliding window time period. I.e. 5 invocations within the last 30 seconds will allow an extra invocation every time the earliest invocation falls out of the window.- evaluate(bucket: buckets.Bucket) CooldownStatus [source]#
Evaluate whether the command should be on cooldown given internal state of this object and the bucket object passed in.
- Parameters:
bucket (
Bucket
) – The bucket to process the cooldown for.- Returns:
The status of the cooldown.
- Return type: