Blocking counting semaphore with exponential backoff.
Summary
Functions
Return the semaphore name for the default key and max connections.
Return the semaphore name for a key and max connections.
Execute fun while holding a semaphore for max_connections.
Execute fun while holding a keyed semaphore with options.
Types
@type semaphore_name() :: {Foundation.Semaphore.Limiter, term(), pos_integer()}
Functions
@spec get_semaphore(pos_integer()) :: semaphore_name()
Return the semaphore name for the default key and max connections.
@spec get_semaphore(term(), pos_integer()) :: semaphore_name()
Return the semaphore name for a key and max connections.
@spec with_semaphore(pos_integer(), (-> result)) :: result when result: any()
Execute fun while holding a semaphore for max_connections.
@spec with_semaphore(term(), pos_integer(), keyword(), (-> result)) :: result when result: any()
Execute fun while holding a keyed semaphore with options.
Options:
:registry- counting semaphore registry (default:Counting.default_registry/0):backoff- backoff options orBackoff.Policy(default: exponential 2ms-50ms, 25% jitter):sleep_fun- sleep function (default:&Process.sleep/1):max_backoff_exponent- cap for exponential backoff attempts (default: 20)