/** * Setup the hosts based on the configuration file * @throws \Exception * @return mixed|void */ public function setup() { if (empty($this->params['hostGroup'])) { $this->params['hostGroup'] = 'default'; } if (empty($this->params['environment'])) { $this->params['environment'] = ServerUtility::determineEnvironment(); } if (isset($this->params['timeout'])) { $this->timeout = $this->params['timeout']; } if ($this->params['forceLocalhost']) { $this->registerHost('master', '127.0.0.1:6379'); return; } $config = $this->getConfig(); $serverGroups = $config['servergroup']; if (!isset($serverGroups[$this->params['hostGroup']])) { throw new \Exception('hostgroup is not a valid group setup in the configuration'); } $servers = $serverGroups[$this->params['hostGroup']]; $this->setMaster($servers); $this->setSlaves($servers); }
/** * This allows override of how environment information is loaded into this * class. * * @return string */ protected function determineEnvironment() { return ServerUtility::determineEnvironment(); }