MediaWiki master
MediaWiki\Settings\Source\EtcdSource Class Reference

Settings loaded from an etcd server. More...

Inherits MediaWiki\Settings\Cache\CacheableSource.

Collaboration diagram for MediaWiki\Settings\Source\EtcdSource:

Public Member Functions

 __construct (array $params=[], ?callable $mapper=null, ?Client $client=null, ?callable $resolver=null)
 Constructs a new EtcdSource for the given etcd server details.
 
 __toString ()
 Returns this etcd source as a string.
 
 allowsStaleLoad ()
 Allow stale results from etcd sources in case all servers become temporarily unavailable.
 
 getExpiryTtl ()
 The cache expiry TTL (in seconds) for this source.
 
 getExpiryWeight ()
 Coefficient used in determining early expiration of cached settings to avoid stampedes.
 
 getHashKey ()
 Returns a naive hash key for use in caching based on an etcd request URL constructed using the etcd request URL.
 
 load ()
 Loads and returns settings from the etcd server.
 

Detailed Description

Settings loaded from an etcd server.

Since
1.38

Definition at line 21 of file EtcdSource.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Settings\Source\EtcdSource::__construct ( array $params = [],
?callable $mapper = null,
?Client $client = null,
?callable $resolver = null )

Constructs a new EtcdSource for the given etcd server details.

Parameters
array$paramsParameter map:
  • host: Etcd server host/domain. Note that an empty host value will result in SRV discovery relative to the host's configured search domain.
  • port: Etcd server port. Defaults to 2379.
  • protocol: Endpoint protocol (http/https). Defaults to 'https'.
  • directory: Top level etcd directory to query for settings.
  • discover: Whether to perform SRV discovery on the given host/domain. Defaults to true.
  • service: service name used in SRV discovery of the default $resolver. Defaults to 'etcd-client-ssl' or 'etcd-client' when protocol is 'https' or 'http' respectively.
?callable$mapperFunction that maps etcd entries to valid MediaWiki config/schema/php-ini values. Defaults to simply returning the structure stored in etcd. Signature: function ( array $settings ): array
?Client$clientGuzzle HTTP client used to query etcd.
?callable$resolverFunction that must return an array of server hostname/port pairs to try. The default resolver will either:
  • use an explicitly given hostname/port if both are provided
  • otherwise attempt DNS SRV discovery at _etcd._tcp.$host
  • fallback to using the host as the etcd server directly Signature: function (): array
Exceptions
SettingsBuilderExceptionif the given host is invalid.

Definition at line 89 of file EtcdSource.php.

References $params.

Member Function Documentation

◆ __toString()

MediaWiki\Settings\Source\EtcdSource::__toString ( )

Returns this etcd source as a string.

Returns
string

Definition at line 215 of file EtcdSource.php.

◆ allowsStaleLoad()

MediaWiki\Settings\Source\EtcdSource::allowsStaleLoad ( )

Allow stale results from etcd sources in case all servers become temporarily unavailable.

Returns
bool

Implements MediaWiki\Settings\Cache\CacheableSource.

Definition at line 149 of file EtcdSource.php.

◆ getExpiryTtl()

MediaWiki\Settings\Source\EtcdSource::getExpiryTtl ( )

The cache expiry TTL (in seconds) for this source.

Returns
int

Implements MediaWiki\Settings\Cache\CacheableSource.

Definition at line 184 of file EtcdSource.php.

◆ getExpiryWeight()

MediaWiki\Settings\Source\EtcdSource::getExpiryWeight ( )

Coefficient used in determining early expiration of cached settings to avoid stampedes.

Returns
float

Implements MediaWiki\Settings\Cache\CacheableSource.

Definition at line 194 of file EtcdSource.php.

◆ getHashKey()

MediaWiki\Settings\Source\EtcdSource::getHashKey ( )

Returns a naive hash key for use in caching based on an etcd request URL constructed using the etcd request URL.

In the case where SRV discovery is performed, the host in the URL will be the SRV record name.

Returns
string

Implements MediaWiki\Settings\Cache\CacheableSource.

Definition at line 206 of file EtcdSource.php.

◆ load()

MediaWiki\Settings\Source\EtcdSource::load ( )

Loads and returns settings from the etcd server.

Exceptions
SettingsBuilderException
Returns
array

Implements MediaWiki\Settings\Source\SettingsSource.

Definition at line 159 of file EtcdSource.php.


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