MediaWiki master
Wikimedia\WRStats\WRStatsFactory Class Reference

The main entry point to WRStats, for creating readers and writers. More...

Public Member Functions

 __construct (StatsStore $store)
 
 createRateLimiter ( $conditions, $prefix='WRStats', $options=[])
 Create a rate limiter.
 
 createReader ( $specs, $prefix='WRStats')
 Create a reader.
 
 createWriter ( $specs, $prefix='WRStats')
 Create a writer.
 
 setCurrentTime ( $now)
 Set a current timestamp to be injected into new instances on creation.
 

Detailed Description

The main entry point to WRStats, for creating readers and writers.

Readers and writers should generally be used for a batch and then discarded. Factory objects can be retained indefinitely.

Since
1.39

Definition at line 13 of file WRStatsFactory.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\WRStats\WRStatsFactory::__construct ( StatsStore $store)
Parameters
StatsStore$store

Definition at line 23 of file WRStatsFactory.php.

Member Function Documentation

◆ createRateLimiter()

Wikimedia\WRStats\WRStatsFactory::createRateLimiter ( $conditions,
$prefix = 'WRStats',
$options = [] )

Create a rate limiter.

Parameters
LimitCondition[]$conditionsAn array in which the key is the condition name, and the value is a LimitCondition describing the limit.
string | string[]$prefixA string or array of strings to prefix before storage keys.
array$optionsAn associative array of options:
  • bucketCount: Each window is divided into this many time buckets. Fetching the current count will typically result in a request for this many keys.
Returns
WRStatsRateLimiter

Definition at line 92 of file WRStatsFactory.php.

◆ createReader()

Wikimedia\WRStats\WRStatsFactory::createReader ( $specs,
$prefix = 'WRStats' )

Create a reader.

Readers gather a batch of read operations, returning promises. The batch is executed when the first promise is resolved.

See also
createWriter
Parameters
array$specs
string | string[]$prefix
Returns
WRStatsReader

Definition at line 71 of file WRStatsFactory.php.

◆ createWriter()

Wikimedia\WRStats\WRStatsFactory::createWriter ( $specs,
$prefix = 'WRStats' )

Create a writer.

Writers gather a batch of increment operations and then commit them when flush() is called, or when the writer is destroyed.

Parameters
array$specsAn array of metric specification arrays, indexed by name, where each element is an associative array with the following keys (all optional):
  • type: (string) Always "counter"
  • resolution: (int|float) The resolution of the counter value. For example, if this is 0.01, counters will be rounded to two decimal places. Necessary because we support backends that only store integers, but we present an interface that allows float values.
  • sequences: (array) An array of sequence specification, each sequence spec being an associative array with the following keys:
    • expiry: (int|float) The expiry time of the counters, in seconds.
    • timeStep: (int|float) The time duration represented by a counter bucket. If this is too small, many buckets will be required, making fetches slower. If this is too large, there will be some jitter in the resulting rates as the current time moves from one bucket to the next.
string | string[]$prefixA string or array of strings to prefix before storage keys.
Returns
WRStatsWriter

Definition at line 53 of file WRStatsFactory.php.

◆ setCurrentTime()

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

Set a current timestamp to be injected into new instances on creation.

Parameters
float | int$nowSeconds since epoch

Definition at line 108 of file WRStatsFactory.php.


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