You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refines logic for configuring wait mode via environment variable,
ensuring consistent behavior when rate limits are exceeded.
Updates documentation for clearer usage guidance.
Enhances RateLimiter comments for maintainability and replaces
generic exceptions with a specific exception type for day window.
* For the full copyright and license information, please view the LICENSE
13
+
* file that was distributed with this source code.
14
+
*/
15
+
3
16
namespace VitexSoftware\Raiffeisenbank\RateLimit;
4
17
5
18
class RateLimiter
6
19
{
7
20
private RateLimitStoreInterface $store;
8
21
private bool $waitMode;
9
22
23
+
/**
24
+
* Create a RateLimiter configured with a storage backend and a handling mode for exceeded limits.
25
+
*
26
+
* @param RateLimitStoreInterface $store storage backend for per-client rate-limit state
27
+
* @param bool $waitModeiftrue, the limiter will wait until the limit window resets; iffalse, it will throw a RateLimitExceededException when limits are exceeded
28
+
*/
10
29
public function __construct(RateLimitStoreInterface $store, bool $waitMode = true)
11
30
{
12
31
$this->store = $store;
13
32
$this->waitMode = $waitMode;
14
33
}
34
+
/**
35
+
* Indicates whether the limiter is configured to wait when a rate limit is exceeded.
36
+
*
37
+
* @return bool `true` if the limiter waits until the rate-limit window expires, `false` otherwise
38
+
*/
15
39
public function isWaitMode(): bool
16
40
{
17
41
return $this->waitMode;
18
42
}
19
43
20
44
/**
21
-
* clientId = fingerprint of the certificate (sha1, serial+issuer, etc.)
22
-
* secondLimits/dayLimits are obtained from API response headers.
45
+
* Stores remaining rate-limit counts for a client for both the one-second and 24-hour windows.
0 commit comments