Browse Source

cache results from ocm end-point discovery

Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
pull/9345/head
Bjoern Schiessle 7 years ago
parent
commit
7ff74ae8ed
No known key found for this signature in database GPG Key ID: 2378A753E2BF04F6
  1. 11
      lib/private/Federation/CloudFederationProviderManager.php

11
lib/private/Federation/CloudFederationProviderManager.php

@ -57,6 +57,9 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager
/** @var ILogger */
private $logger;
/** @var array cache OCM end-points */
private $ocmEndPoints = [];
private $supportedAPIVersion = '1.0-proposal1';
/**
@ -208,10 +211,16 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager
* @return string
*/
protected function getOCMEndPoint($url) {
if (isset($this->ocmEndPoints[$url])) {
return $this->ocmEndPoints[$url];
}
$client = $this->httpClientService->newClient();
try {
$response = $client->get($url . '/ocm-provider/', ['timeout' => 10, 'connect_timeout' => 10]);
} catch (\Exception $e) {
$this->ocmEndPoints[$url] = '';
return '';
}
@ -221,9 +230,11 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager
$supportedVersion = isset($result['apiVersion']) && $result['apiVersion'] === $this->supportedAPIVersion;
if (isset($result['endPoint']) && $supportedVersion) {
$this->ocmEndPoints[$url] = $result['endPoint'];
return $result['endPoint'];
}
$this->ocmEndPoints[$url] = '';
return '';
}

Loading…
Cancel
Save