mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-20 10:48:40 +01:00
Remove "mysql.configuration-provider" configuration option
Summary: Ref T11044. This was old Facebook cruft for reading configuration from SMC (and maybe doing some other questionable things). See D183. (See also D175 for discussion of this from 2011.) In modern Phabricator, you can subclass `SiteConfig` to provide dynamic configuration, and we do so in the Phacility cluster. This lets you change any config, and change in response to requests (e.g., for instancing) and is generally more powerful than this mechanism was. This configuration provider theoretically let you roll your own replication or partitioning, but in practice I believe no one ever did, and no one ever could have anyway without more support in the upstream (for migrations, read-after-write, etc). Test Plan: - Grepped for removed option. - Browsed around with clustering off. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11044 Differential Revision: https://secure.phabricator.com/D16911
This commit is contained in:
parent
4da74166fe
commit
e6bfa1bd23
7 changed files with 19 additions and 117 deletions
|
@ -345,8 +345,6 @@ phutil_register_library_map(array(
|
|||
'DarkConsoleStartupPlugin' => 'applications/console/plugin/DarkConsoleStartupPlugin.php',
|
||||
'DarkConsoleXHProfPlugin' => 'applications/console/plugin/DarkConsoleXHProfPlugin.php',
|
||||
'DarkConsoleXHProfPluginAPI' => 'applications/console/plugin/xhprof/DarkConsoleXHProfPluginAPI.php',
|
||||
'DatabaseConfigurationProvider' => 'infrastructure/storage/configuration/DatabaseConfigurationProvider.php',
|
||||
'DefaultDatabaseConfigurationProvider' => 'infrastructure/storage/configuration/DefaultDatabaseConfigurationProvider.php',
|
||||
'DifferentialAction' => 'applications/differential/constants/DifferentialAction.php',
|
||||
'DifferentialActionEmailCommand' => 'applications/differential/command/DifferentialActionEmailCommand.php',
|
||||
'DifferentialAddCommentView' => 'applications/differential/view/DifferentialAddCommentView.php',
|
||||
|
@ -4949,10 +4947,6 @@ phutil_register_library_map(array(
|
|||
'DarkConsoleStartupPlugin' => 'DarkConsolePlugin',
|
||||
'DarkConsoleXHProfPlugin' => 'DarkConsolePlugin',
|
||||
'DarkConsoleXHProfPluginAPI' => 'Phobject',
|
||||
'DefaultDatabaseConfigurationProvider' => array(
|
||||
'Phobject',
|
||||
'DatabaseConfigurationProvider',
|
||||
),
|
||||
'DifferentialAction' => 'Phobject',
|
||||
'DifferentialActionEmailCommand' => 'MetaMTAEmailTransactionCommand',
|
||||
'DifferentialAddCommentView' => 'AphrontView',
|
||||
|
|
|
@ -344,6 +344,10 @@ final class PhabricatorExtraConfigSetupCheck extends PhabricatorSetupCheck {
|
|||
'mysql.implementation' => pht(
|
||||
'Phabricator now automatically selects the best available '.
|
||||
'MySQL implementation.'),
|
||||
|
||||
'mysql.configuration-provider' => pht(
|
||||
'Phabricator now has application-level management of partitioning '.
|
||||
'and replicas.'),
|
||||
);
|
||||
|
||||
return $ancient_config;
|
||||
|
|
|
@ -35,19 +35,6 @@ final class PhabricatorMySQLConfigOptions
|
|||
->setHidden(true)
|
||||
->setDescription(
|
||||
pht('MySQL password to use when connecting to the database.')),
|
||||
$this->newOption(
|
||||
'mysql.configuration-provider',
|
||||
'class',
|
||||
'DefaultDatabaseConfigurationProvider')
|
||||
->setLocked(true)
|
||||
->setBaseClass('DatabaseConfigurationProvider')
|
||||
->setSummary(
|
||||
pht('Configure database configuration class.'))
|
||||
->setDescription(
|
||||
pht(
|
||||
'Phabricator chooses which database to connect to through a '.
|
||||
'swappable configuration provider. You almost certainly do not '.
|
||||
'need to change this.')),
|
||||
$this->newOption('storage.default-namespace', 'string', 'phabricator')
|
||||
->setLocked(true)
|
||||
->setSummary(
|
||||
|
|
|
@ -569,17 +569,20 @@ final class PhabricatorDatabaseRef
|
|||
}
|
||||
|
||||
public static function newIndividualRef() {
|
||||
$conf = PhabricatorEnv::newObjectFromConfig(
|
||||
'mysql.configuration-provider',
|
||||
array(null, 'w', null));
|
||||
$default_user = PhabricatorEnv::getEnvConfig('mysql.user');
|
||||
$default_pass = new PhutilOpaqueEnvelope(
|
||||
PhabricatorEnv::getEnvConfig('mysql.pass'));
|
||||
$default_host = PhabricatorEnv::getEnvConfig('mysql.host');
|
||||
$default_port = PhabricatorEnv::getEnvConfig('mysql.port');
|
||||
|
||||
return id(new self())
|
||||
->setHost($conf->getHost())
|
||||
->setPort($conf->getPort())
|
||||
->setUser($conf->getUser())
|
||||
->setPass($conf->getPassword())
|
||||
->setUser($default_user)
|
||||
->setPass($default_pass)
|
||||
->setHost($default_host)
|
||||
->setPort($default_port)
|
||||
->setIsIndividual(true)
|
||||
->setIsMaster(true);
|
||||
->setIsMaster(true)
|
||||
->setIsDefaultPartition(true);
|
||||
}
|
||||
|
||||
public static function getAllReplicaDatabaseRefs() {
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
|
||||
interface DatabaseConfigurationProvider {
|
||||
|
||||
public function __construct(
|
||||
LiskDAO $dao = null,
|
||||
$mode = 'r',
|
||||
$namespace = 'phabricator');
|
||||
|
||||
public function getUser();
|
||||
public function getPassword();
|
||||
public function getHost();
|
||||
public function getPort();
|
||||
public function getDatabase();
|
||||
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class DefaultDatabaseConfigurationProvider
|
||||
extends Phobject
|
||||
implements DatabaseConfigurationProvider {
|
||||
|
||||
private $dao;
|
||||
private $mode;
|
||||
private $namespace;
|
||||
|
||||
public function __construct(
|
||||
LiskDAO $dao = null,
|
||||
$mode = 'r',
|
||||
$namespace = 'phabricator') {
|
||||
|
||||
$this->dao = $dao;
|
||||
$this->mode = $mode;
|
||||
$this->namespace = $namespace;
|
||||
}
|
||||
|
||||
public function getUser() {
|
||||
return PhabricatorEnv::getEnvConfig('mysql.user');
|
||||
}
|
||||
|
||||
public function getPassword() {
|
||||
return new PhutilOpaqueEnvelope(PhabricatorEnv::getEnvConfig('mysql.pass'));
|
||||
}
|
||||
|
||||
public function getHost() {
|
||||
return PhabricatorEnv::getEnvConfig('mysql.host');
|
||||
}
|
||||
|
||||
public function getPort() {
|
||||
return PhabricatorEnv::getEnvConfig('mysql.port');
|
||||
}
|
||||
|
||||
public function getDatabase() {
|
||||
if (!$this->getDao()) {
|
||||
return null;
|
||||
}
|
||||
return $this->namespace.'_'.$this->getDao()->getApplicationName();
|
||||
}
|
||||
|
||||
protected function getDao() {
|
||||
return $this->dao;
|
||||
}
|
||||
|
||||
}
|
|
@ -60,15 +60,10 @@ abstract class PhabricatorLiskDAO extends LiskDAO {
|
|||
$this->raiseImproperWrite($database);
|
||||
}
|
||||
|
||||
$is_cluster = (bool)PhabricatorEnv::getEnvConfig('cluster.databases');
|
||||
if ($is_cluster) {
|
||||
$connection = $this->newClusterConnection(
|
||||
$this->getApplicationName(),
|
||||
$database,
|
||||
$mode);
|
||||
} else {
|
||||
$connection = $this->newBasicConnection($database, $mode, $namespace);
|
||||
}
|
||||
$connection = $this->newClusterConnection(
|
||||
$this->getApplicationName(),
|
||||
$database,
|
||||
$mode);
|
||||
|
||||
// TODO: This should be testing if the mode is "r", but that would probably
|
||||
// break a lot of things. Perform a more narrow test for readonly mode
|
||||
|
@ -96,23 +91,6 @@ abstract class PhabricatorLiskDAO extends LiskDAO {
|
|||
return $connection;
|
||||
}
|
||||
|
||||
private function newBasicConnection($database, $mode, $namespace) {
|
||||
$conf = PhabricatorEnv::newObjectFromConfig(
|
||||
'mysql.configuration-provider',
|
||||
array($this, $mode, $namespace));
|
||||
|
||||
return PhabricatorDatabaseRef::newRawConnection(
|
||||
array(
|
||||
'user' => $conf->getUser(),
|
||||
'pass' => $conf->getPassword(),
|
||||
'host' => $conf->getHost(),
|
||||
'port' => $conf->getPort(),
|
||||
'database' => $database,
|
||||
'retries' => 3,
|
||||
'timeout' => 10,
|
||||
));
|
||||
}
|
||||
|
||||
private function newClusterConnection($application, $database, $mode) {
|
||||
$master = PhabricatorDatabaseRef::getMasterDatabaseRefForApplication(
|
||||
$application);
|
||||
|
|
Loading…
Add table
Reference in a new issue