Skip to content

Commit 7ff74ae

Browse files
committed
cache results from ocm end-point discovery
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
1 parent ce567b6 commit 7ff74ae

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/private/Federation/CloudFederationProviderManager.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager
5757
/** @var ILogger */
5858
private $logger;
5959

60+
/** @var array cache OCM end-points */
61+
private $ocmEndPoints = [];
62+
6063
private $supportedAPIVersion = '1.0-proposal1';
6164

6265
/**
@@ -208,10 +211,16 @@ public function isReady() {
208211
* @return string
209212
*/
210213
protected function getOCMEndPoint($url) {
214+
215+
if (isset($this->ocmEndPoints[$url])) {
216+
return $this->ocmEndPoints[$url];
217+
}
218+
211219
$client = $this->httpClientService->newClient();
212220
try {
213221
$response = $client->get($url . '/ocm-provider/', ['timeout' => 10, 'connect_timeout' => 10]);
214222
} catch (\Exception $e) {
223+
$this->ocmEndPoints[$url] = '';
215224
return '';
216225
}
217226

@@ -221,9 +230,11 @@ protected function getOCMEndPoint($url) {
221230
$supportedVersion = isset($result['apiVersion']) && $result['apiVersion'] === $this->supportedAPIVersion;
222231

223232
if (isset($result['endPoint']) && $supportedVersion) {
233+
$this->ocmEndPoints[$url] = $result['endPoint'];
224234
return $result['endPoint'];
225235
}
226236

237+
$this->ocmEndPoints[$url] = '';
227238
return '';
228239
}
229240

0 commit comments

Comments
 (0)