Skip to content

Commit

Permalink
Initial commit. Added connection handler and keyvalue implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
valicm committed Nov 19, 2020
0 parents commit 1bc5155
Show file tree
Hide file tree
Showing 15 changed files with 1,572 additions and 0 deletions.
11 changes: 11 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "drupal/dynamodb_client",
"type": "drupal-module",
"description": "Client interface use for communication with Amazon DynamoDB",
"homepage": "http://drupal.org/project/dynamodb_client",
"license": "GPL-2.0+",
"minimum-stability": "dev",
"require": {
"aws/aws-sdk-php": "^3"
}
}
5 changes: 5 additions & 0 deletions dynamodb_client.info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: 'Amazon DynamoDB'
type: module
description: 'Client interface for Amazon DynamoDB'
core_version_requirement: ^8.9 || ^9
package: Performance
8 changes: 8 additions & 0 deletions dynamodb_client.services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
dynamodb_client.client_factory:
class: Drupal\dynamodb_client\ClientFactory
arguments: [ default ]

dynamodb_client.connection:
class: Drupal\dynamodb_client\Connection
arguments: ['@settings']
5 changes: 5 additions & 0 deletions modules/keyvalue/dynamodb_keyvalue.info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: 'Amazon DynamoDB Key/Value'
type: module
description: 'Amazon DynamoDB Key/Value storage implementation for Drupal 8/9'
core_version_requirement: ^8.9 || ^9
package: Performance
109 changes: 109 additions & 0 deletions modules/keyvalue/dynamodb_keyvalue.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?php

use Drupal\dynamodb_client\DynamoDb;

/**
* Implements hook_install().
*/
function dynamodb_keyvalue_install() {
$connection = DynamoDb::connection();
foreach (dynamodb_keyvalue_tables_definition() as $id => $table) {
$billing = DynamoDb::getBillingMode($id);
$table += $billing;
$connection->createTable($table);
}

}

/**
* Implements hook_uninstall().
*/
function dynamodb_keyvalue_uninstall() {
$connection = DynamoDb::connection();
$connection->deleteTable(['TableName' => 'key_value']);
$connection->deleteTable(['TableName' => 'key_value_expire']);
}

/**
* Definition for tables.
*
* @return array[]
* Return keyed array of tables.
*/
function dynamodb_keyvalue_tables_definition() {
return [
'key_value' => [
'TableName' => 'key_value',
'AttributeDefinitions' => [
[
'AttributeName' => 'collection',
'AttributeType' => 'S'
],
[
'AttributeName' => 'name',
'AttributeType' => 'S'
],
],
'KeySchema' => [
[
'AttributeName' => 'collection',
'KeyType' => 'HASH' //Partition key
],
[
'AttributeName' => 'name',
'KeyType' => 'RANGE' //Sort key
],
],
],
'key_value_expire' => [
'TableName' => 'key_value_expire',
'AttributeDefinitions' => [
[
'AttributeName' => 'collection',
'AttributeType' => 'S',
],
[
'AttributeName' => 'name',
'AttributeType' => 'S',
],
[
'AttributeName' => 'expire',
'AttributeType' => 'N',
],
],
'LocalSecondaryIndexes' => [
[
'IndexName' => 'expired_index',
'KeySchema' => [
[
'AttributeName' => 'collection',
'KeyType' => 'HASH'
],
[
'AttributeName' => 'expire',
'KeyType' => 'RANGE'
],
],
'Projection' => [
'ProjectionType' => 'INCLUDE',
'NonKeyAttributes' => ['name']
]
],
],
'KeySchema' => [
[
'AttributeName' => 'collection',
'KeyType' => 'HASH'
],
[
'AttributeName' => 'name',
'KeyType' => 'RANGE'
],
],
'TimeToLiveSpecification' => [
'Enabled' => TRUE,
'AttributeName' => 'expire',
],
]
];
}
13 changes: 13 additions & 0 deletions modules/keyvalue/dynamodb_keyvalue.services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
services:
keyvalue.dynamodb:
class: Drupal\dynamodb_keyvalue\KeyValueStore\KeyValueDynamoDbFactory
arguments: ['@serialization.phpserialize', '@dynamodb_client.connection']

keyvalue.expirable.dynamodb:
class: Drupal\dynamodb_keyvalue\KeyValueStore\KeyValueDynamoDbExpirableFactory
arguments: [ '@serialization.phpserialize', '@dynamodb_client.connection']

dynamodb_keyvalue.migrate:
class: Drupal\dynamodb_keyvalue\MigrateDatabaseKeyValue
arguments:
[ '@database', '@serialization.yaml', '@dynamodb_client.connection' ]
Loading

0 comments on commit 1bc5155

Please sign in to comment.