Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3530989
D3989.id12491.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D3989.id12491.diff
View Options
diff --git a/services/lib/src/DatabaseManagerBase.cpp b/services/lib/src/DatabaseManagerBase.cpp
--- a/services/lib/src/DatabaseManagerBase.cpp
+++ b/services/lib/src/DatabaseManagerBase.cpp
@@ -1,5 +1,7 @@
#include "DatabaseManagerBase.h"
+#include "Item.h"
+
#include <aws/core/utils/Outcome.h>
#include <aws/dynamodb/model/DeleteItemRequest.h>
diff --git a/services/tunnelbroker/CMakeLists.txt b/services/tunnelbroker/CMakeLists.txt
--- a/services/tunnelbroker/CMakeLists.txt
+++ b/services/tunnelbroker/CMakeLists.txt
@@ -57,7 +57,7 @@
DEPENDS "${proto}"
)
-file(GLOB SOURCE_CODE "./src/*.cpp" "./src/**/*.cpp")
+file(GLOB_RECURSE SOURCE_CODE "./src/*.cpp")
set(GENERATED_CODE ${proto_srcs} ${proto_hdrs} ${grpc_srcs} ${grpc_hdrs})
file(GLOB DOUBLE_CONVERSION_SOURCES "./lib/double-conversion/double-conversion/*.cc")
diff --git a/services/tunnelbroker/Dockerfile b/services/tunnelbroker/Dockerfile
--- a/services/tunnelbroker/Dockerfile
+++ b/services/tunnelbroker/Dockerfile
@@ -25,6 +25,7 @@
COPY services/lib/docker/ scripts/
COPY services/tunnelbroker/docker/* docker/
COPY services/tunnelbroker/ .
+COPY services/lib/src/* src/
RUN scripts/build_service.sh
diff --git a/services/tunnelbroker/src/Database/DatabaseManager.cpp b/services/tunnelbroker/src/Database/DatabaseManager.cpp
--- a/services/tunnelbroker/src/Database/DatabaseManager.cpp
+++ b/services/tunnelbroker/src/Database/DatabaseManager.cpp
@@ -1,4 +1,5 @@
#include "DatabaseManager.h"
+#include "DynamoDBTools.h"
namespace comm {
namespace network {
@@ -53,7 +54,8 @@
Aws::DynamoDB::Model::DeleteItemRequest request;
request.SetTableName(item.getTableName());
request.AddKey(
- item.getPrimaryKey(), Aws::DynamoDB::Model::AttributeValue(key));
+ item.getPrimaryKey().partitionKey,
+ Aws::DynamoDB::Model::AttributeValue(key));
const Aws::DynamoDB::Model::DeleteItemOutcome &outcome =
getDynamoDBClient()->DeleteItem(request);
diff --git a/services/tunnelbroker/src/Database/DeviceSessionItem.h b/services/tunnelbroker/src/Database/DeviceSessionItem.h
--- a/services/tunnelbroker/src/Database/DeviceSessionItem.h
+++ b/services/tunnelbroker/src/Database/DeviceSessionItem.h
@@ -31,7 +31,8 @@
static const std::string FIELD_CHECKPOINT_TIME;
static const std::string FIELD_EXPIRE;
- std::string getPrimaryKey() const override;
+ PrimaryKey getPrimaryKey() const override;
+ PrimaryKeyValue getPrimaryKeyValue() const override;
std::string getTableName() const override;
std::string getSessionID() const;
std::string getDeviceID() const;
diff --git a/services/tunnelbroker/src/Database/DeviceSessionItem.cpp b/services/tunnelbroker/src/Database/DeviceSessionItem.cpp
--- a/services/tunnelbroker/src/Database/DeviceSessionItem.cpp
+++ b/services/tunnelbroker/src/Database/DeviceSessionItem.cpp
@@ -83,8 +83,12 @@
config::ConfigManager::OPTION_DYNAMODB_SESSIONS_TABLE);
}
-std::string DeviceSessionItem::getPrimaryKey() const {
- return DeviceSessionItem::FIELD_SESSION_ID;
+PrimaryKey DeviceSessionItem::getPrimaryKey() const {
+ return PrimaryKey(DeviceSessionItem::FIELD_SESSION_ID);
+}
+
+PrimaryKeyValue DeviceSessionItem::getPrimaryKeyValue() const {
+ return PrimaryKeyValue(this->sessionID);
}
std::string DeviceSessionItem::getSessionID() const {
diff --git a/services/tunnelbroker/src/Database/Item.h b/services/tunnelbroker/src/Database/Item.h
deleted file mode 100644
--- a/services/tunnelbroker/src/Database/Item.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#pragma once
-
-#include <aws/core/Aws.h>
-#include <aws/dynamodb/DynamoDBClient.h>
-
-#include <string>
-
-namespace comm {
-namespace network {
-namespace database {
-
-typedef Aws::Map<Aws::String, Aws::DynamoDB::Model::AttributeValue>
- AttributeValues;
-
-class Item {
- virtual void validate() const = 0;
-
-public:
- virtual std::string getTableName() const = 0;
- virtual std::string getPrimaryKey() const = 0;
- virtual void assignItemFromDatabase(const AttributeValues &itemFromDB) = 0;
-};
-
-} // namespace database
-} // namespace network
-} // namespace comm
diff --git a/services/tunnelbroker/src/Database/MessageItem.h b/services/tunnelbroker/src/Database/MessageItem.h
--- a/services/tunnelbroker/src/Database/MessageItem.h
+++ b/services/tunnelbroker/src/Database/MessageItem.h
@@ -29,7 +29,8 @@
static const std::string FIELD_CREATED_AT;
static const std::string INDEX_TO_DEVICE_ID;
- std::string getPrimaryKey() const override;
+ PrimaryKey getPrimaryKey() const override;
+ PrimaryKeyValue getPrimaryKeyValue() const override;
std::string getTableName() const override;
std::string getMessageID() const;
std::string getFromDeviceID() const;
diff --git a/services/tunnelbroker/src/Database/MessageItem.cpp b/services/tunnelbroker/src/Database/MessageItem.cpp
--- a/services/tunnelbroker/src/Database/MessageItem.cpp
+++ b/services/tunnelbroker/src/Database/MessageItem.cpp
@@ -68,8 +68,12 @@
config::ConfigManager::OPTION_DYNAMODB_MESSAGES_TABLE);
}
-std::string MessageItem::getPrimaryKey() const {
- return MessageItem::FIELD_MESSAGE_ID;
+PrimaryKey MessageItem::getPrimaryKey() const {
+ return PrimaryKey(MessageItem::FIELD_MESSAGE_ID);
+}
+
+PrimaryKeyValue MessageItem::getPrimaryKeyValue() const {
+ return PrimaryKeyValue(this->messageID);
}
std::string MessageItem::getMessageID() const {
diff --git a/services/tunnelbroker/src/Database/PublicKeyItem.h b/services/tunnelbroker/src/Database/PublicKeyItem.h
--- a/services/tunnelbroker/src/Database/PublicKeyItem.h
+++ b/services/tunnelbroker/src/Database/PublicKeyItem.h
@@ -18,7 +18,8 @@
static const std::string FIELD_DEVICE_ID;
static const std::string FIELD_PUBLIC_KEY;
- std::string getPrimaryKey() const override;
+ PrimaryKey getPrimaryKey() const override;
+ PrimaryKeyValue getPrimaryKeyValue() const override;
std::string getTableName() const override;
std::string getDeviceID() const;
std::string getPublicKey() const;
diff --git a/services/tunnelbroker/src/Database/PublicKeyItem.cpp b/services/tunnelbroker/src/Database/PublicKeyItem.cpp
--- a/services/tunnelbroker/src/Database/PublicKeyItem.cpp
+++ b/services/tunnelbroker/src/Database/PublicKeyItem.cpp
@@ -43,8 +43,12 @@
config::ConfigManager::OPTION_DYNAMODB_SESSIONS_PUBLIC_KEY_TABLE);
}
-std::string PublicKeyItem::getPrimaryKey() const {
- return PublicKeyItem::FIELD_DEVICE_ID;
+PrimaryKey PublicKeyItem::getPrimaryKey() const {
+ return PrimaryKey(PublicKeyItem::FIELD_DEVICE_ID);
+}
+
+PrimaryKeyValue PublicKeyItem::getPrimaryKeyValue() const {
+ return PrimaryKeyValue(this->deviceID);
}
std::string PublicKeyItem::getDeviceID() const {
diff --git a/services/tunnelbroker/src/Database/SessionSignItem.h b/services/tunnelbroker/src/Database/SessionSignItem.h
--- a/services/tunnelbroker/src/Database/SessionSignItem.h
+++ b/services/tunnelbroker/src/Database/SessionSignItem.h
@@ -19,7 +19,8 @@
static const std::string FIELD_DEVICE_ID;
static const std::string FIELD_EXPIRE;
- std::string getPrimaryKey() const override;
+ PrimaryKey getPrimaryKey() const override;
+ PrimaryKeyValue getPrimaryKeyValue() const override;
std::string getTableName() const override;
std::string getSign() const;
std::string getDeviceID() const;
diff --git a/services/tunnelbroker/src/Database/SessionSignItem.cpp b/services/tunnelbroker/src/Database/SessionSignItem.cpp
--- a/services/tunnelbroker/src/Database/SessionSignItem.cpp
+++ b/services/tunnelbroker/src/Database/SessionSignItem.cpp
@@ -47,8 +47,12 @@
config::ConfigManager::OPTION_DYNAMODB_SESSIONS_VERIFICATION_TABLE);
}
-std::string SessionSignItem::getPrimaryKey() const {
- return SessionSignItem::FIELD_DEVICE_ID;
+PrimaryKey SessionSignItem::getPrimaryKey() const {
+ return PrimaryKey(SessionSignItem::FIELD_DEVICE_ID);
+}
+
+PrimaryKeyValue SessionSignItem::getPrimaryKeyValue() const {
+ return PrimaryKeyValue(this->deviceID);
}
std::string SessionSignItem::getSign() const {
diff --git a/services/tunnelbroker/src/Tools/AwsTools.h b/services/tunnelbroker/src/Tools/AwsTools.h
--- a/services/tunnelbroker/src/Tools/AwsTools.h
+++ b/services/tunnelbroker/src/Tools/AwsTools.h
@@ -11,7 +11,6 @@
namespace network {
Aws::String getAwsRegion();
-std::unique_ptr<Aws::DynamoDB::DynamoDBClient> getDynamoDBClient();
} // namespace network
} // namespace comm
diff --git a/services/tunnelbroker/src/Tools/AwsTools.cpp b/services/tunnelbroker/src/Tools/AwsTools.cpp
--- a/services/tunnelbroker/src/Tools/AwsTools.cpp
+++ b/services/tunnelbroker/src/Tools/AwsTools.cpp
@@ -16,15 +16,5 @@
return {};
}
-std::unique_ptr<Aws::DynamoDB::DynamoDBClient> getDynamoDBClient() {
- Aws::Client::ClientConfiguration config;
- config.region = getAwsRegion();
- if (config.region.empty()) {
- throw std::runtime_error(
- "Error: AWS region is not provided in the ~/.aws/config");
- }
- return std::make_unique<Aws::DynamoDB::DynamoDBClient>(config);
-}
-
} // namespace network
} // namespace comm
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 26, 5:31 AM (11 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2703965
Default Alt Text
D3989.id12491.diff (8 KB)
Attached To
Mode
D3989: [services] Lib - Tunnelbroker - Use sources
Attached
Detach File
Event Timeline
Log In to Comment