diff --git a/services/backup/docker-server/contents/server/src/Reactors/server/PullBackupReactor.h b/services/backup/docker-server/contents/server/src/Reactors/server/PullBackupReactor.h --- a/services/backup/docker-server/contents/server/src/Reactors/server/PullBackupReactor.h +++ b/services/backup/docker-server/contents/server/src/Reactors/server/PullBackupReactor.h @@ -1,12 +1,18 @@ #pragma once +#include "BlobGetClientReactor.h" +#include "DatabaseManager.h" #include "ServerWriteReactorBase.h" +#include "ServiceBlobClient.h" #include "../_generated/backup.grpc.pb.h" #include "../_generated/backup.pb.h" +#include + #include #include +#include #include namespace comm { @@ -16,19 +22,55 @@ class PullBackupReactor : public ServerWriteReactorBase< backup::PullBackupRequest, backup::PullBackupResponse> { + + enum class State { + COMPACTION = 1, + LOGS = 2, + }; + + std::shared_ptr backupItem; + std::shared_ptr getReactor; + std::shared_ptr> dataChunks; + ServiceBlobClient blobClient; + State state = State::COMPACTION; + + void initializeGetReactor(const std::string &holder); + public: - using ServerWriteReactorBase< - backup::PullBackupRequest, - backup::PullBackupResponse>::ServerWriteReactorBase; + PullBackupReactor(const backup::PullBackupRequest *request); + + void initialize() override; std::unique_ptr writeResponse(backup::PullBackupResponse *response) override; }; +PullBackupReactor::PullBackupReactor(const backup::PullBackupRequest *request) + : ServerWriteReactorBase< + backup::PullBackupRequest, + backup::PullBackupResponse>(request), + dataChunks(std::make_shared>(100)) { +} + +void PullBackupReactor::initializeGetReactor(const std::string &holder) { + if (this->backupItem == nullptr) { + throw std::runtime_error("not enough data to initialize get reactor"); + } + if (this->getReactor == nullptr) { + this->getReactor = std::make_shared( + holder, this->dataChunks); + this->getReactor->request.set_holder(holder); + this->blobClient.get(this->getReactor); + } +} + +void PullBackupReactor::initialize() { + throw std::runtime_error("unimplemented"); +} + std::unique_ptr PullBackupReactor::writeResponse(backup::PullBackupResponse *response) { - // TODO handle request - return std::make_unique(grpc::Status(grpc::StatusCode::UNIMPLEMENTED, "unimplemented")); + throw std::runtime_error("unimplemented"); } } // namespace reactor