MediaWiki master
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
Use WRStatsFactory::createReader instead
Parameters
StatsStore$store
array<string,array>$specs
string | string[]$prefix

Definition at line 31 of file WRStatsReader.php.

Member Function Documentation

◆ fetch()

Wikimedia\WRStats\WRStatsReader::fetch ( )

Perform any queued fetch operations.

Definition at line 126 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 76 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 115 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
Utility for resolution in RatePromise
Parameters
string$metricName
EntityKey$entity
MetricSpec$metricSpec
SequenceSpec$seqSpec
TimeRange$range
Returns
float|int

Definition at line 168 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 52 of file WRStatsReader.php.

◆ perDay()

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

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

Parameters
array<mixed,RatePromise>$rates
Returns
array<mixed,float>

Definition at line 291 of file WRStatsReader.php.

◆ perHour()

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

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

Parameters
array<mixed,RatePromise>$rates
Returns
array<mixed,float>

Definition at line 277 of file WRStatsReader.php.

◆ perMinute()

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

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

Parameters
array<mixed,RatePromise>$rates
Returns
array<mixed,float>

Definition at line 263 of file WRStatsReader.php.

◆ perSecond()

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

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

Parameters
array<mixed,RatePromise>$rates
Returns
array<mixed,float>

Definition at line 249 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 147 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 139 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 64 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
array<mixed,RatePromise>$rates
Returns
array<mixed,float|int>

Definition at line 235 of file WRStatsReader.php.


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