Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3719928
D4476.id14843.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D4476.id14843.diff
View Options
diff --git a/services/tunnelbroker/src/Database/DatabaseManager.h b/services/tunnelbroker/src/Database/DatabaseManager.h
--- a/services/tunnelbroker/src/Database/DatabaseManager.h
+++ b/services/tunnelbroker/src/Database/DatabaseManager.h
@@ -47,6 +47,9 @@
std::vector<std::shared_ptr<MessageItem>>
findMessageItemsByReceiver(const std::string &toDeviceID);
void removeMessageItem(const std::string &messageID);
+ void removeMessageItemsByIDsForDeviceID(
+ std::vector<std::string> &messageIDs,
+ const std::string &toDeviceID);
};
} // namespace database
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
@@ -209,6 +209,30 @@
this->innerRemoveItem(*item);
}
+void DatabaseManager::removeMessageItemsByIDsForDeviceID(
+ std::vector<std::string> &messageIDs,
+ const std::string &toDeviceID) {
+ std::vector<Aws::DynamoDB::Model::WriteRequest> writeRequests;
+ for (std::string &messageID : messageIDs) {
+ Aws::DynamoDB::Model::DeleteRequest deleteRequest;
+ deleteRequest.AddKey(
+ MessageItem::FIELD_TO_DEVICE_ID,
+ Aws::DynamoDB::Model::AttributeValue(toDeviceID));
+ deleteRequest.AddKey(
+ MessageItem::FIELD_MESSAGE_ID,
+ Aws::DynamoDB::Model::AttributeValue(messageID));
+ Aws::DynamoDB::Model::WriteRequest currentWriteRequest;
+ currentWriteRequest.SetDeleteRequest(deleteRequest);
+ writeRequests.push_back(currentWriteRequest);
+ }
+ this->innerBatchWriteItem(
+ MESSAGES_TABLE_NAME,
+ DYNAMODB_MAX_BATCH_ITEMS,
+ DYNAMODB_BACKOFF_FIRST_RETRY_DELAY,
+ DYNAMODB_MAX_BACKOFF_TIME,
+ writeRequests);
+}
+
} // namespace database
} // namespace network
} // namespace comm
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 9, 12:05 PM (9 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2834436
Default Alt Text
D4476.id14843.diff (1 KB)
Attached To
Mode
D4476: [services] Tunnelbroker - Database function that removes messages by a batch using messageIDs and receiver DeviceID.
Attached
Detach File
Event Timeline
Log In to Comment