Skip to content

Commit

Permalink
define timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemo64 committed Mar 1, 2020
1 parent 5a5f0a0 commit 3ff798c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -43,5 +44,8 @@
},
"scripts": {
"test": "phpunit tests"
},
"config": {
"sort-packages": true
}
}
8 changes: 8 additions & 0 deletions src/RdsDataDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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'],
Expand Down

0 comments on commit 3ff798c

Please sign in to comment.