Tinkex.RetrySemaphore (Tinkex v0.2.2)
View SourceBlocking semaphore wrapper used to cap concurrent sampling retry executions.
Uses the semaphore library's global ETS-backed semaphore. Each distinct
max_connections value maps to its own semaphore name.
Summary
Functions
Returns a specification to start this module under a supervisor.
Return the semaphore name for a given max_connections.
Return the semaphore name for a given key and max_connections.
Start the semaphore supervisor and underlying semaphore server.
Execute fun while holding the semaphore for max_connections.
Blocks until capacity is available.
Execute fun while holding a keyed semaphore. Callers can provide a unique
key to isolate capacity between clients even when max_connections matches.
Types
@type semaphore_name() :: {:tinkex_retry, term(), pos_integer()}
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec get_semaphore(pos_integer()) :: semaphore_name()
Return the semaphore name for a given max_connections.
@spec get_semaphore(term(), pos_integer()) :: semaphore_name()
Return the semaphore name for a given key and max_connections.
Start the semaphore supervisor and underlying semaphore server.
@spec with_semaphore(pos_integer(), (-> term())) :: term()
Execute fun while holding the semaphore for max_connections.
Blocks until capacity is available.
@spec with_semaphore(term(), pos_integer(), (-> term())) :: term()
Execute fun while holding a keyed semaphore. Callers can provide a unique
key to isolate capacity between clients even when max_connections matches.