diff --git a/services/backup/docker-server/contents/server/src/Reactors/server/SendLogReactor.h b/services/backup/docker-server/contents/server/src/Reactors/server/SendLogReactor.h --- a/services/backup/docker-server/contents/server/src/Reactors/server/SendLogReactor.h +++ b/services/backup/docker-server/contents/server/src/Reactors/server/SendLogReactor.h @@ -2,6 +2,7 @@ #include "Constants.h" #include "ServerReadReactorBase.h" +#include "ServiceBlobClient.h" #include "../_generated/backup.grpc.pb.h" #include "../_generated/backup.pb.h" @@ -32,13 +33,18 @@ PersistenceMethod persistenceMethod = PersistenceMethod::UNKNOWN; std::string userID; std::string backupID; + std::string hash; // either the value itself which is a dump of a single operation (if // `persistedInBlob` is false) or the holder to blob (if `persistedInBlob` is // true) std::string value; + std::condition_variable blobDoneCV; + std::shared_ptr putReactor; + ServiceBlobClient blobClient; void storeInDatabase(); std::string generateLogID(); + void initializePutReactor(); void storeInBlob(const std::string &data) { } @@ -68,6 +74,22 @@ return generateRandomString(); } +void SendLogReactor::initializePutReactor() { + if (this->value.empty()) { + throw std::runtime_error( + "put reactor cannot be initialized with empty value"); + } + if (this->hash.empty()) { + throw std::runtime_error( + "put reactor cannot be initialized with empty hash"); + } + if (this->putReactor == nullptr) { + this->putReactor = std::make_shared( + this->value, this->hash, &this->blobDoneCV); + this->blobClient.put(this->putReactor); + } +} + std::unique_ptr SendLogReactor::readRequest(backup::SendLogRequest request) { switch (this->state) {