final class SDKConnector in Apigee Edge 8
Same name in this branch
- 8 src/SDKConnector.php \Drupal\apigee_edge\SDKConnector
- 8 modules/apigee_edge_debug/src/SDKConnector.php \Drupal\apigee_edge_debug\SDKConnector
- 8 tests/modules/apigee_edge_test/src/SDKConnector.php \Drupal\apigee_edge_test\SDKConnector
Service decorator for SDKConnector.
Hierarchy
- class \Drupal\apigee_edge\SDKConnector implements SDKConnectorInterface
- class \Drupal\apigee_edge_test\SDKConnector implements SDKConnectorInterface
Expanded class hierarchy of SDKConnector
1 string reference to 'SDKConnector'
- apigee_edge_test.services.yml in tests/
modules/ apigee_edge_test/ apigee_edge_test.services.yml - tests/modules/apigee_edge_test/apigee_edge_test.services.yml
1 service uses SDKConnector
- apigee_edge_test.sdk_connector in tests/
modules/ apigee_edge_test/ apigee_edge_test.services.yml - Drupal\apigee_edge_test\SDKConnector
File
- tests/
modules/ apigee_edge_test/ src/ SDKConnector.php, line 42
Namespace
Drupal\apigee_edge_testView source
final class SDKConnector extends DecoratedSDKConnector implements SDKConnectorInterface {
/**
* The decorated SDK connector service.
*
* @var \Drupal\apigee_edge\SDKConnector
*/
private $innerService;
/**
* A logger instance.
*
* @var \Drupal\Core\Logger\LoggerChannelInterface
*/
private $logger;
/**
* Constructs a new SDKConnector.
*
* @param \Drupal\apigee_edge\SDKConnectorInterface $inner_service
* The decorated SDK connector service.
* @param \Drupal\Core\Logger\LoggerChannelInterface $logger
* Logger interface.
* @param \Drupal\Core\Http\ClientFactory $clientFactory
* Http client.
* @param \Drupal\key\KeyRepositoryInterface $key_repository
* The key repository.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* Entity type manager service.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The factory for configuration objects.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
* Module handler service.
* @param \Drupal\Core\Extension\InfoParserInterface $infoParser
* Info file parser service.
*/
public function __construct(SDKConnectorInterface $inner_service, LoggerChannelInterface $logger, ClientFactory $clientFactory, KeyRepositoryInterface $key_repository, EntityTypeManagerInterface $entity_type_manager, ConfigFactoryInterface $config_factory, ModuleHandlerInterface $moduleHandler, InfoParserInterface $infoParser) {
$this->innerService = $inner_service;
$this->logger = $logger;
parent::__construct($clientFactory, $key_repository, $entity_type_manager, $config_factory, $moduleHandler, $infoParser);
}
/**
* {@inheritdoc}
*/
public function buildClient(Authentication $authentication, ?string $endpoint = NULL, array $options = []) : ClientInterface {
$decider = function (RequestInterface $request, Exception $e) {
// Only retry API calls that failed with this specific error.
if ($e instanceof ApiResponseException && $e
->getEdgeErrorCode() === 'messaging.adaptors.http.flow.ApplicationNotFound') {
$this->logger
->warning('Restarting request because it failed. {error_code}: {exception}.', [
'error_code' => $e
->getEdgeErrorCode(),
'exception' => $e
->getMessage(),
]);
return TRUE;
}
return FALSE;
};
// Use the retry plugin in tests.
return $this->innerService
->buildClient($authentication, $endpoint, [
Client::CONFIG_RETRY_PLUGIN_CONFIG => [
'retries' => 5,
'exception_decider' => $decider,
'exception_delay' => function (RequestInterface $request, Exception $e, $retries) : int {
return $retries * 15000000;
},
],
]);
}
/**
* {@inheritdoc}
*/
protected function httpClientConfiguration() : array {
return $this->innerService
->httpClientConfiguration();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SDKConnector:: |
private static | property | The client object. | |
SDKConnector:: |
private | property | The HTTP client factory. | |
SDKConnector:: |
protected | property | The config factory. | |
SDKConnector:: |
private static | property | The currently used credentials object. | |
SDKConnector:: |
protected | property | The entity type manager. | |
SDKConnector:: |
protected | property | The info parser. | |
SDKConnector:: |
private | property | The decorated SDK connector service. | |
SDKConnector:: |
protected | property | The key repository. | |
SDKConnector:: |
private | property | A logger instance. | |
SDKConnector:: |
protected | property | The module handler service. | |
SDKConnector:: |
private static | property | Custom user agent prefix. | |
SDKConnector:: |
public | function |
Returns a pre-configured API client with the provided credentials. Overrides SDKConnector:: |
|
SDKConnector:: |
private | function | Builds credentials, which depends on the KeyType of the key entity. | |
SDKConnector:: |
public | function |
Returns the http client. Overrides SDKConnectorInterface:: |
|
SDKConnector:: |
private | function | Returns the credentials object used by the API client. | |
SDKConnector:: |
public | function |
Gets the organization. Overrides SDKConnectorInterface:: |
|
SDKConnector:: |
protected | function |
Get HTTP client overrides for Apigee Edge API client. Overrides SDKConnector:: |
|
SDKConnector:: |
private | function | Changes credentials used by the API client. | |
SDKConnector:: |
public | function |
Test connection with the Edge Management Server. Overrides SDKConnectorInterface:: |
|
SDKConnector:: |
protected | function | Generates a custom user agent prefix. | |
SDKConnector:: |
public | function |
Constructs a new SDKConnector. Overrides SDKConnector:: |