Commit 0a453043 authored by Bas de Nooijer's avatar Bas de Nooijer

- added an event for server failover logging

- added support for optional events to plugin system
parent 15379ebf
......@@ -457,10 +457,12 @@ class Solarium_Client extends Solarium_Configurable
protected function _callPlugins($event, $params, $resultOverride = false)
{
foreach ($this->_pluginInstances AS $plugin) {
$result = call_user_func_array(array($plugin, $event), $params);
if (method_exists($plugin, $event)) {
$result = call_user_func_array(array($plugin, $event), $params);
if ($result !== null && $resultOverride) {
return $result;
if ($result !== null && $resultOverride) {
return $result;
}
}
}
}
......
......@@ -452,20 +452,22 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract
*/
protected function _getLoadbalancedResponse($request) {
$this->_serverExcludes = array(); // reset for each query
$adapter = $this->_client->getAdapter();
if ($this->getFailoverEnabled() == true) {
$e = new Solarium_Exception('Maximum number of loadbalancer retries reached');
$this->_serverExcludes = array(); // reset
for($i=0; $i<=$this->getFailoverMaxRetries(); $i++) {
$options = $this->_getRandomServerOptions();
$adapter->setOptions($options);
try{
try {
return $adapter->execute($request);
} catch(Solarium_Client_HttpException $e) {
// ignore HTTP errors, try again
// ignore HTTP errors and try again
// but do issue an event for things like logging
$this->_client->triggerEvent('LoadbalancerServerFail', array($options, $e));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment