diff --git a/services/backup/docker-server/contents/server/src/Reactors/server/CreateNewBackupReactor.h b/services/backup/docker-server/contents/server/src/Reactors/server/CreateNewBackupReactor.h --- a/services/backup/docker-server/contents/server/src/Reactors/server/CreateNewBackupReactor.h +++ b/services/backup/docker-server/contents/server/src/Reactors/server/CreateNewBackupReactor.h @@ -20,12 +20,14 @@ backup::CreateNewBackupRequest, backup::CreateNewBackupResponse> { enum class State { - KEY_ENTROPY = 1, - DATA_HASH = 2, - DATA_CHUNKS = 3, + USER_ID = 1, + KEY_ENTROPY = 2, + DATA_HASH = 3, + DATA_CHUNKS = 4, }; - State state = State::KEY_ENTROPY; + State state = State::USER_ID; + std::string userID; std::string keyEntropy; std::string dataHash; std::string backupID; @@ -56,6 +58,14 @@ // as there may be multiple threads from the pool taking over here const std::lock_guard lock(this->blobPutClientReactorMutex); switch (this->state) { + case State::USER_ID: { + if (!request.has_userid()) { + throw std::runtime_error("user id expected but not received"); + } + this->userID = request.userid(); + this->state = State::KEY_ENTROPY; + return nullptr; + } case State::KEY_ENTROPY: { if (!request.has_keyentropy()) { throw std::runtime_error( 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 @@ -16,6 +16,13 @@ class SendLogReactor : public ServerReadReactorBase< backup::SendLogRequest, google::protobuf::Empty> { + enum class State { + USER_ID = 1, + LOG_CHUNK = 2, + }; + + State state = State::USER_ID; + std::string userID; public: using ServerReadReactorBase:: @@ -28,10 +35,17 @@ std::unique_ptr SendLogReactor::readRequest(backup::SendLogRequest request) { - // TODO implement - std::cout << "handle request log chunk " << request.logdata().size() - << std::endl; - return nullptr; + switch (this->state) { + case State::USER_ID: { + if (!request.has_userid()) { + throw std::runtime_error("user id expected but not received"); + } + this->userID = request.userid(); + this->state = State::LOG_CHUNK; + return nullptr; + }; + } + throw std::runtime_error("send log - invalid state"); } void SendLogReactor::doneCallback() {