This module provides functionality for consuming throttle events from
a Redis stream in a threaded manner. It allows for the creation of
threads to handle throttle events, with configurable idle and wait
timeouts. The module also provides predicates to set and retrieve
timeout values for specific keys and fields.
Broadcast Events
The module broadcasts the following events:
threaded_throttle(up, Key, Field) : A throttle event has been
received for the specified Key and Field.
threaded_throttle(adjust, Key, Field, Value) : The throttle value
has been adjusted for the specified Key and Field.
threaded_throttle(down, Key, Field) : The throttle event has
completed for the specified Key and Field.
- consume_threaded_throttle(+Key:atom, +Field:atom) is det
- Listens to a Redis stream for throttle events on the specified Key
and Field. When an event is received, it creates a thread to handle
the event and sends the value to that thread.
- Arguments:
-
| Key | - The Redis stream key to listen to. |
| Field | - The field within the Redis stream to listen for events. |
- unconsume_threaded_throttle(+Key:atom, +Field:atom) is det
- Stops listening to the Redis stream for throttle events on the
specified Key and Field.
- Arguments:
-
| Key | - The Redis stream key to stop listening to. |
| Field | - The field within the Redis stream to stop listening for
events. |
- current_threaded_throttle_timeout(+When:atom, +Key:atom, +Field:atom, -Timeout:number) is det
- Retrieves the current timeout value for the specified Key and Field
based on the When condition (idle or wait). If a specific timeout
has been set for the Key and Field, it will be used; otherwise, the
default setting will be retrieved from the application settings.
- Arguments:
-
| When | - The condition for which the timeout is being retrieved
(idle or wait). |
| Key | - The Redis stream key for which the timeout is being
retrieved. |
| Field | - The field within the Redis stream for which the timeout
is being retrieved. |
| Timeout | - The timeout value in seconds. |
- set_threaded_throttle_timeout(+When:atom, +Key:atom, +Field:atom, +Timeout:number) is det
- Sets a specific timeout value for the specified Key and Field based
on the When condition (idle or wait). This allows for dynamic
adjustment of timeout values for different throttle events.
- Arguments:
-
| When | - The condition for which the timeout is being set (idle or
wait). |
| Key | - The Redis stream key for which the timeout is being set. |
| Field | - The field within the Redis stream for which the timeout
is being set. |
| Timeout | - The timeout value in seconds. |
- exit_threaded_throttle(+Key:atom, +Field:atom) is det
- Exits the threaded throttle for the specified Key and Field by
signaling the associated thread to terminate. If a thread exists for
the Key and Field, it will be signaled to throw an exit_thread
exception, allowing for graceful termination of the thread.