MediaWiki REL1_39
Wikimedia\WRStats\WRStatsReader Class Reference

Readers gather a batch of read operations, returning promises. More...

Public Member Functions

 __construct (StatsStore $store, $specs, $prefix)
 
 fetch ()
 Perform any queued fetch operations.
 
 getRate ( $metricName, ?EntityKey $entity, TimeRange $range)
 Queue a fetch operation.
 
 getRates ( $metricNames, ?EntityKey $entity, TimeRange $range)
 Queue a batch of fetch operations for different metrics with the same time range.
 
 internalGetCount ( $metricName, EntityKey $entity, MetricSpec $metricSpec, SequenceSpec $seqSpec, TimeRange $range)
 
 latest ( $numSeconds)
 Get a TimeRange for some period ending at the current time.
 
 perDay ( $rates)
 Resolve a batch of RatePromise objects, returning their per-day rates.
 
 perHour ( $rates)
 Resolve a batch of RatePromise objects, returning their per-hour rates.
 
 perMinute ( $rates)
 Resolve a batch of RatePromise objects, returning their per-minute rates.
 
 perSecond ( $rates)
 Resolve a batch of RatePromise objects, returning their per-second rates.
 
 resetCurrentTime ()
 Clear the current time so that it will be filled with the real current time on the next call.
 
 setCurrentTime ( $now)
 Set the current time to be used in latest() etc.
 
 timeRange ( $start, $end)
 Get a specified time range.
 
 total ( $rates)
 Resolve a batch of RatePromise objects, returning their counter totals, indexed as in the input array.
 

Detailed Description

Readers gather a batch of read operations, returning promises.

The batch is executed when the first promise is resolved.

Since
1.39

Definition at line 11 of file WRStatsReader.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\WRStats\WRStatsReader::__construct ( StatsStore $store,
$specs,
$prefix )
Access: internal
Parameters
StatsStore$store
array$specs
string | string[]$prefix

Definition at line 32 of file WRStatsReader.php.

Member Function Documentation

◆ fetch()

Wikimedia\WRStats\WRStatsReader::fetch ( )

Perform any queued fetch operations.

Definition at line 127 of file WRStatsReader.php.

Referenced by Wikimedia\WRStats\WRStatsReader\internalGetCount().

◆ getRate()

Wikimedia\WRStats\WRStatsReader::getRate ( $metricName,
?EntityKey $entity,
TimeRange $range )

Queue a fetch operation.

Parameters
string$metricNameThe metric name, the key into $specs.
EntityKey | null$entityAdditional storage key components
TimeRange$rangeThe time range to fetch
Returns
RatePromise

Definition at line 77 of file WRStatsReader.php.

Referenced by Wikimedia\WRStats\WRStatsReader\getRates().

◆ getRates()

Wikimedia\WRStats\WRStatsReader::getRates ( $metricNames,
?EntityKey $entity,
TimeRange $range )

Queue a batch of fetch operations for different metrics with the same time range.

Parameters
string[]$metricNames
EntityKey | null$entity
TimeRange$range
Returns
RatePromise[]

Definition at line 116 of file WRStatsReader.php.

References Wikimedia\WRStats\WRStatsReader\getRate().

◆ internalGetCount()

Wikimedia\WRStats\WRStatsReader::internalGetCount ( $metricName,
EntityKey $entity,
MetricSpec $metricSpec,
SequenceSpec $seqSpec,
TimeRange $range )
Access: internal
Method for promise resolution
Parameters
string$metricName
EntityKey$entity
MetricSpec$metricSpec
SequenceSpec$seqSpec
TimeRange$range
Returns
float|int

Definition at line 172 of file WRStatsReader.php.

References Wikimedia\WRStats\WRStatsReader\fetch(), and Wikimedia\WRStats\TimeRange\getDuration().

◆ latest()

Wikimedia\WRStats\WRStatsReader::latest ( $numSeconds)

Get a TimeRange for some period ending at the current time.

Note that this will use the same value of the current time for subsequent calls until resetCurrentTime() is called.

Parameters
int | float$numSeconds
Returns
TimeRange

Definition at line 53 of file WRStatsReader.php.

◆ perDay()

Wikimedia\WRStats\WRStatsReader::perDay ( $rates)

Resolve a batch of RatePromise objects, returning their per-day rates.

Parameters
RatePromise[]$rates
Returns
float[]

Definition at line 295 of file WRStatsReader.php.

◆ perHour()

Wikimedia\WRStats\WRStatsReader::perHour ( $rates)

Resolve a batch of RatePromise objects, returning their per-hour rates.

Parameters
RatePromise[]$rates
Returns
float[]

Definition at line 281 of file WRStatsReader.php.

◆ perMinute()

Wikimedia\WRStats\WRStatsReader::perMinute ( $rates)

Resolve a batch of RatePromise objects, returning their per-minute rates.

Parameters
RatePromise[]$rates
Returns
float[]

Definition at line 267 of file WRStatsReader.php.

◆ perSecond()

Wikimedia\WRStats\WRStatsReader::perSecond ( $rates)

Resolve a batch of RatePromise objects, returning their per-second rates.

Parameters
RatePromise[]$rates
Returns
float[]

Definition at line 253 of file WRStatsReader.php.

◆ resetCurrentTime()

Wikimedia\WRStats\WRStatsReader::resetCurrentTime ( )

Clear the current time so that it will be filled with the real current time on the next call.

Definition at line 148 of file WRStatsReader.php.

◆ setCurrentTime()

Wikimedia\WRStats\WRStatsReader::setCurrentTime ( $now)

Set the current time to be used in latest() etc.

Parameters
int | float$now

Definition at line 140 of file WRStatsReader.php.

◆ timeRange()

Wikimedia\WRStats\WRStatsReader::timeRange ( $start,
$end )

Get a specified time range.

Parameters
int | float$startThe UNIX time of the start of the range
int | float$endThe UNIX time of the end of the range
Returns
TimeRange

Definition at line 65 of file WRStatsReader.php.

◆ total()

Wikimedia\WRStats\WRStatsReader::total ( $rates)

Resolve a batch of RatePromise objects, returning their counter totals, indexed as in the input array.

Parameters
RatePromise[]$rates
Returns
array<string,float|int>

Definition at line 239 of file WRStatsReader.php.


The documentation for this class was generated from the following file: