diff --git a/services/backup/docker-server/contents/server/src/BackupServiceImpl.h b/services/backup/docker-server/contents/server/src/BackupServiceImpl.h --- a/services/backup/docker-server/contents/server/src/BackupServiceImpl.h +++ b/services/backup/docker-server/contents/server/src/BackupServiceImpl.h @@ -8,31 +8,27 @@ namespace comm { namespace network { -class BackupServiceImpl final : public backup::BackupService::Service { +class BackupServiceImpl final : public backup::BackupService::CallbackService { public: BackupServiceImpl(); virtual ~BackupServiceImpl(); - grpc::Status CreateNewBackup( - grpc::ServerContext *context, - grpc::ServerReaderWriter< - backup::CreateNewBackupResponse, - backup::CreateNewBackupRequest> *stream) override; - grpc::Status SendLog( - grpc::ServerContext *context, - grpc::ServerReader *reader, - google::protobuf::Empty *response) override; - grpc::Status RecoverBackupKey( - grpc::ServerContext *context, - grpc::ServerReaderWriter< - backup::RecoverBackupKeyResponse, - backup::RecoverBackupKeyRequest> *stream) override; - grpc::Status PullBackup( - grpc::ServerContext *context, - grpc::ServerReaderWriter< - backup::PullBackupResponse, - backup::PullBackupRequest> *stream) override; + grpc::ServerBidiReactor< + backup::CreateNewBackupRequest, + backup::CreateNewBackupResponse> * + CreateNewBackup(grpc::CallbackServerContext *context) override; + + grpc::ServerBidiReactor * + SendLog(grpc::CallbackServerContext *context) override; + + grpc::ServerBidiReactor< + backup::RecoverBackupKeyRequest, + backup::RecoverBackupKeyResponse> * + RecoverBackupKey(grpc::CallbackServerContext *context) override; + + grpc::ServerBidiReactor + *PullBackup(grpc::CallbackServerContext *context) override; }; } // namespace network diff --git a/services/backup/docker-server/contents/server/src/BackupServiceImpl.cpp b/services/backup/docker-server/contents/server/src/BackupServiceImpl.cpp --- a/services/backup/docker-server/contents/server/src/BackupServiceImpl.cpp +++ b/services/backup/docker-server/contents/server/src/BackupServiceImpl.cpp @@ -1,5 +1,9 @@ #include "BackupServiceImpl.h" +#include "PakeAuthenticationHandler.h" +#include "ReactorBase.h" +#include "WalletAuthenticationHandler.h" + #include namespace comm { @@ -13,35 +17,78 @@ Aws::ShutdownAPI({}); } -grpc::Status BackupServiceImpl::CreateNewBackup( - grpc::ServerContext *context, - grpc::ServerReaderWriter< - backup::CreateNewBackupResponse, - backup::CreateNewBackupRequest> *stream) { - return grpc::Status(grpc::StatusCode::UNIMPLEMENTED, "not implemented yet"); +grpc::ServerBidiReactor< + backup::CreateNewBackupRequest, + backup::CreateNewBackupResponse> * +BackupServiceImpl::CreateNewBackup(grpc::CallbackServerContext *context) { + class CreateNewBackupReactor : public ReactorBase< + backup::CreateNewBackupRequest, + backup::CreateNewBackupResponse> { + public: + backup::CreateNewBackupResponse + handleRequest(backup::CreateNewBackupRequest request) override { + throw EndConnectionError(); + // TODO handle request + // backup::CreateNewBackupResponse response; + // return response; + } + }; + + return new CreateNewBackupReactor(); } -grpc::Status BackupServiceImpl::SendLog( - grpc::ServerContext *context, - grpc::ServerReader *reader, - google::protobuf::Empty *response) { - return grpc::Status(grpc::StatusCode::UNIMPLEMENTED, "not implemented yet"); +grpc::ServerBidiReactor * +BackupServiceImpl::SendLog(grpc::CallbackServerContext *context) { + class SendLogReactor + : public ReactorBase { + public: + google::protobuf::Empty + handleRequest(backup::SendLogRequest request) override { + throw EndConnectionError(); + // TODO handle request + return google::protobuf::Empty(); + } + }; + + return new SendLogReactor(); } -grpc::Status BackupServiceImpl::RecoverBackupKey( - grpc::ServerContext *context, - grpc::ServerReaderWriter< - backup::RecoverBackupKeyResponse, - backup::RecoverBackupKeyRequest> *stream) { - return grpc::Status(grpc::StatusCode::UNIMPLEMENTED, "not implemented yet"); +grpc::ServerBidiReactor< + backup::RecoverBackupKeyRequest, + backup::RecoverBackupKeyResponse> * +BackupServiceImpl::RecoverBackupKey(grpc::CallbackServerContext *context) { + class RecoverBackupKeyReactor : public ReactorBase< + backup::RecoverBackupKeyRequest, + backup::RecoverBackupKeyResponse> { + public: + backup::RecoverBackupKeyResponse + handleRequest(backup::RecoverBackupKeyRequest request) override { + throw EndConnectionError(); + // TODO handle request + // backup::RecoverBackupKeyResponse response; + // return response; + } + }; + + return new RecoverBackupKeyReactor(); } -grpc::Status BackupServiceImpl::PullBackup( - grpc::ServerContext *context, - grpc::ServerReaderWriter< - backup::PullBackupResponse, - backup::PullBackupRequest> *stream) { - return grpc::Status(grpc::StatusCode::UNIMPLEMENTED, "not implemented yet"); +grpc::ServerBidiReactor * +BackupServiceImpl::PullBackup(grpc::CallbackServerContext *context) { + class PullBackupReactor : public ReactorBase< + backup::PullBackupRequest, + backup::PullBackupResponse> { + public: + backup::PullBackupResponse + handleRequest(backup::PullBackupRequest request) override { + throw EndConnectionError(); + // TODO handle request + // backup::PullBackupResponse response; + // return response; + } + }; + + return new PullBackupReactor(); } } // namespace network