diff --git a/composer.json b/composer.json index 937fc32..c364899 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,8 @@ "require": { "php": "~7.1", "aws/aws-sdk-php": "^3.98", - "doctrine/dbal": "^2.7" + "doctrine/dbal": "^2.7", + "guzzlehttp/guzzle": "^6.2.1|^7.0" }, "require-dev": { "phpunit/phpunit": "^9.0" @@ -43,5 +44,8 @@ }, "scripts": { "test": "phpunit tests" + }, + "config": { + "sort-packages": true } } diff --git a/src/RdsDataDriver.php b/src/RdsDataDriver.php index 3a8cda5..8506076 100644 --- a/src/RdsDataDriver.php +++ b/src/RdsDataDriver.php @@ -3,8 +3,10 @@ namespace Nemo64\DbalRdsData; +use Aws\Handler\GuzzleV6\GuzzleHandler; use Aws\RDSDataService\RDSDataServiceClient; use Doctrine\DBAL\Driver; +use GuzzleHttp\Client; class RdsDataDriver extends Driver\AbstractMySQLDriver { @@ -26,6 +28,12 @@ public function connect(array $params, $username = null, $password = null, array $options['credentials']['secret'] = $password; } + $options['http_handler'] = new GuzzleHandler(new Client([ + // all calls to the data-api will time out after 45 seconds + // https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html + 'timeout' => 45, + ])); + return new RdsDataConnection( new RDSDataServiceClient($options), $driverOptions['resourceArn'],