MediaWiki REL1_39
|
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 8 of file WRStatsRateLimiter.php.
Wikimedia\WRStats\WRStatsRateLimiter::__construct | ( | StatsStore | $store, |
$conditions, | |||
$prefix = 'WRLimit', | |||
$options = [] ) |
StatsStore | $store | |
LimitCondition[] | $conditions | |
string | string[] | $prefix | |
array | $options |
Definition at line 33 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 63 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 172 of file WRStatsRateLimiter.php.
Wikimedia\WRStats\WRStatsRateLimiter::incrBatch | ( | array | $operations | ) |
Unconditionally increment a set of metrics.
LimitOperation[] | $operations |
Definition at line 186 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 76 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 93 of file WRStatsRateLimiter.php.
Wikimedia\WRStats\WRStatsRateLimiter::resetCurrentTime | ( | ) |
Forget a time set with setCurrentTime().
Use the actual current time.
Definition at line 213 of file WRStatsRateLimiter.php.
Wikimedia\WRStats\WRStatsRateLimiter::setCurrentTime | ( | $now | ) |
Set the current time.
float | int | $now |
Definition at line 206 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 139 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 156 of file WRStatsRateLimiter.php.
const Wikimedia\WRStats\WRStatsRateLimiter::BUCKET_COUNT = 30 |
Default number of time buckets per action.
Definition at line 21 of file WRStatsRateLimiter.php.
Referenced by Wikimedia\WRStats\WRStatsRateLimiter\__construct().