|
MediaWiki master
|
A rate limiter with a WRStats backend. More...
Public Member Functions | |
| __construct (StatsStore $store, $conditions, $prefix='WRLimit', $options=[]) | |
| createBatch ( $defaultAmount=1) | |
| Create a batch object for rate limiting of multiple metrics. | |
| incr (string $condName, ?EntityKey $entityKey=null, $amount=1) | |
| Unconditionally increment a metric. | |
| incrBatch (array $operations) | |
| Unconditionally increment a set of metrics. | |
| peek (string $condName, ?EntityKey $entityKey=null, $amount=1) | |
| Check whether executing a single operation would exceed the defined limit, without incrementing the count. | |
| peekBatch (array $operations) | |
| Check whether executing a given set of increment operations would exceed any defined limit, without actually performing the increment. | |
| resetCurrentTime () | |
| Forget a time set with setCurrentTime(). | |
| setCurrentTime ( $now) | |
| Set the current time. | |
| tryIncr (string $condName, ?EntityKey $entityKey=null, $amount=1) | |
| Check if the limit would be exceeded by incrementing the specified metric. | |
| tryIncrBatch (array $operations) | |
| Check if the limit would be exceeded by execution of the given set of increment operations. | |
Public Attributes | |
| const | BUCKET_COUNT = 30 |
| Default number of time buckets per action. | |
A rate limiter with a WRStats backend.
Definition at line 10 of file WRStatsRateLimiter.php.
| Wikimedia\WRStats\WRStatsRateLimiter::__construct | ( | StatsStore | $store, |
| $conditions, | |||
| $prefix = 'WRLimit', | |||
| $options = [] ) |
| StatsStore | $store | |
| array<string,LimitCondition> | $conditions | |
| string | string[] | $prefix | |
| array | $options |
Definition at line 32 of file WRStatsRateLimiter.php.
References Wikimedia\WRStats\WRStatsRateLimiter\BUCKET_COUNT.
| Wikimedia\WRStats\WRStatsRateLimiter::createBatch | ( | $defaultAmount = 1 | ) |
Create a batch object for rate limiting of multiple metrics.
| int | $defaultAmount | The amount to increment each metric by, if no amount is passed to localOp/globalOp |
Definition at line 62 of file WRStatsRateLimiter.php.
| Wikimedia\WRStats\WRStatsRateLimiter::incr | ( | string | $condName, |
| ?EntityKey | $entityKey = null, | ||
| $amount = 1 ) |
Unconditionally increment a metric.
| string | $condName | |
| EntityKey | null | $entityKey | |
| int | $amount |
Definition at line 170 of file WRStatsRateLimiter.php.
| Wikimedia\WRStats\WRStatsRateLimiter::incrBatch | ( | array | $operations | ) |
Unconditionally increment a set of metrics.
| LimitOperation[] | $operations |
Definition at line 184 of file WRStatsRateLimiter.php.
| Wikimedia\WRStats\WRStatsRateLimiter::peek | ( | string | $condName, |
| ?EntityKey | $entityKey = null, | ||
| $amount = 1 ) |
Check whether executing a single operation would exceed the defined limit, without incrementing the count.
| string | $condName | |
| EntityKey | null | $entityKey | |
| int | $amount |
Definition at line 75 of file WRStatsRateLimiter.php.
| Wikimedia\WRStats\WRStatsRateLimiter::peekBatch | ( | array | $operations | ) |
Check whether executing a given set of increment operations would exceed any defined limit, without actually performing the increment.
| LimitOperation[] | $operations |
Definition at line 92 of file WRStatsRateLimiter.php.
| Wikimedia\WRStats\WRStatsRateLimiter::resetCurrentTime | ( | ) |
Forget a time set with setCurrentTime().
Use the actual current time.
Definition at line 211 of file WRStatsRateLimiter.php.
| Wikimedia\WRStats\WRStatsRateLimiter::setCurrentTime | ( | $now | ) |
Set the current time.
| float | int | $now |
Definition at line 204 of file WRStatsRateLimiter.php.
| Wikimedia\WRStats\WRStatsRateLimiter::tryIncr | ( | string | $condName, |
| ?EntityKey | $entityKey = null, | ||
| $amount = 1 ) |
Check if the limit would be exceeded by incrementing the specified metric.
If not, increment it.
| string | $condName | |
| EntityKey | null | $entityKey | |
| int | $amount |
Definition at line 137 of file WRStatsRateLimiter.php.
| Wikimedia\WRStats\WRStatsRateLimiter::tryIncrBatch | ( | array | $operations | ) |
Check if the limit would be exceeded by execution of the given set of increment operations.
If not, perform the increments.
| LimitOperation[] | $operations |
Definition at line 154 of file WRStatsRateLimiter.php.
| const Wikimedia\WRStats\WRStatsRateLimiter::BUCKET_COUNT = 30 |
Default number of time buckets per action.
Definition at line 23 of file WRStatsRateLimiter.php.
Referenced by Wikimedia\WRStats\WRStatsRateLimiter\__construct().