mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
fix with empty gradido nodes
This commit is contained in:
parent
0737a4f1f3
commit
f0b8c978d2
@ -42,7 +42,11 @@ class JsonRpcRequestClientComponent extends Component
|
||||
$http = new Client();
|
||||
|
||||
try {
|
||||
$response = $http->post($this->pickGradidoNodeUrl(), $message, ['type' => 'json']);
|
||||
$url = $this->pickGradidoNodeUrl();
|
||||
if(is_array($url)) {
|
||||
return $url;
|
||||
}
|
||||
$response = $http->post($url, $message, ['type' => 'json']);
|
||||
} catch(Exception $e) {
|
||||
return ['state' => 'error', 'type' => 'http exception', 'details' => $e->getMessage()];
|
||||
}
|
||||
@ -65,7 +69,10 @@ class JsonRpcRequestClientComponent extends Component
|
||||
|
||||
static public function pickGradidoNodeUrl()
|
||||
{
|
||||
$gradidoNodes = Configure::read('GradidoNode');
|
||||
$gradidoNodes = Configure::read('GradidoNode');
|
||||
if(count($gradidoNodes) == 0) {
|
||||
return ['state' => 'error', 'msg' => 'no gradido nodes in config'];
|
||||
}
|
||||
$i = rand(0, count($gradidoNodes)-1);
|
||||
return $gradidoNodes[$i]['host'] . ':' . $gradidoNodes[$i]['port'];
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user