Skip to content

Commit

Permalink
Switch to async aws
Browse files Browse the repository at this point in the history
  • Loading branch information
RikudouSage committed Apr 4, 2022
1 parent 24e1c34 commit ece7c10
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/Dynamo/DynamoDbTableCreator.php
Expand Up @@ -2,8 +2,10 @@

namespace Rikudou\DynamoDbCache\Dynamo;

use Aws\DynamoDb\DynamoDbClient;
use Aws\DynamoDb\Exception\DynamoDbException;
use AsyncAws\Core\Exception\Http\ClientException;
use AsyncAws\DynamoDb\DynamoDbClient;
use AsyncAws\DynamoDb\Enum\TableStatus;
use AsyncAws\DynamoDb\Exception\ResourceNotFoundException;
use ReflectionObject;
use Rikudou\DynamoDbCache\DynamoDbCache;

Expand Down Expand Up @@ -56,11 +58,8 @@ public function exists(): bool
]);

return true;
} catch (DynamoDbException $e) {
if ($e->getAwsErrorCode() === 'ResourceNotFoundException') {
return false;
}
throw $e;
} catch (ResourceNotFoundException $e) {
return false;
}
}

Expand Down Expand Up @@ -95,7 +94,7 @@ public function create(string $mode = self::MODE_PAY_PER_REQUEST): bool
]);

return true;
} catch (DynamoDbException $e) {
} catch (ClientException $e) {
return false;
}
}
Expand Down Expand Up @@ -139,8 +138,11 @@ private function isActive(): bool
}
$result = $this->awsClient->describeTable([
'TableName' => $this->tableName,
])->get('Table');
])->getTable();
if ($result === null) {
return false;
}

return $result['TableStatus'] === 'ACTIVE';
return $result->getTableStatus() === TableStatus::ACTIVE;
}
}

0 comments on commit ece7c10

Please sign in to comment.