Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3390856
D3512.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D3512.diff
View Options
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,7 +1,7 @@
#include "BackupServiceImpl.h"
-#include "ReadReactorBase.h"
#include "ServerBidiReactorBase.h"
+#include "ServerReadReactorBase.h"
#include <aws/core/Aws.h>
@@ -39,12 +39,13 @@
grpc::ServerReadReactor<backup::SendLogRequest> *BackupServiceImpl::SendLog(
grpc::CallbackServerContext *context,
google::protobuf::Empty *response) {
- class SendLogReactor : public ReadReactorBase<
+ class SendLogReactor : public reactor::ServerReadReactorBase<
backup::SendLogRequest,
google::protobuf::Empty> {
public:
- using ReadReactorBase<backup::SendLogRequest, google::protobuf::Empty>::
- ReadReactorBase;
+ using ServerReadReactorBase<
+ backup::SendLogRequest,
+ google::protobuf::Empty>::ServerReadReactorBase;
std::unique_ptr<grpc::Status>
readRequest(backup::SendLogRequest request) override {
// TODO handle request
diff --git a/services/backup/docker-server/contents/server/src/Reactors/ReadReactorBase.h b/services/backup/docker-server/contents/server/src/Reactors/server/base-reactors/ServerReadReactorBase.h
rename from services/backup/docker-server/contents/server/src/Reactors/ReadReactorBase.h
rename to services/backup/docker-server/contents/server/src/Reactors/server/base-reactors/ServerReadReactorBase.h
--- a/services/backup/docker-server/contents/server/src/Reactors/ReadReactorBase.h
+++ b/services/backup/docker-server/contents/server/src/Reactors/server/base-reactors/ServerReadReactorBase.h
@@ -1,59 +1,75 @@
#pragma once
#include <grpcpp/grpcpp.h>
+
#include <iostream>
#include <memory>
#include <string>
namespace comm {
namespace network {
+namespace reactor {
template <class Request, class Response>
-class ReadReactorBase : public grpc::ServerReadReactor<Request> {
+class ServerReadReactorBase : public grpc::ServerReadReactor<Request> {
Request request;
+ void terminate(grpc::Status status);
+
protected:
Response *response;
+ grpc::Status status;
public:
- ReadReactorBase(Response *response);
+ ServerReadReactorBase(Response *response);
void OnDone() override;
void OnReadDone(bool ok) override;
virtual std::unique_ptr<grpc::Status> readRequest(Request request) = 0;
+ virtual void initialize(){};
+ virtual void doneCallback(){};
};
template <class Request, class Response>
-ReadReactorBase<Request, Response>::ReadReactorBase(Response *response)
+void ServerReadReactorBase<Request, Response>::terminate(grpc::Status status) {
+ this->status = status;
+ this->Finish(status);
+}
+
+template <class Request, class Response>
+ServerReadReactorBase<Request, Response>::ServerReadReactorBase(
+ Response *response)
: response(response) {
+ this->initialize();
this->StartRead(&this->request);
}
template <class Request, class Response>
-void ReadReactorBase<Request, Response>::OnDone() {
+void ServerReadReactorBase<Request, Response>::OnDone() {
+ this->doneCallback();
delete this;
}
template <class Request, class Response>
-void ReadReactorBase<Request, Response>::OnReadDone(bool ok) {
+void ServerReadReactorBase<Request, Response>::OnReadDone(bool ok) {
if (!ok) {
- this->Finish(
- grpc::Status(grpc::StatusCode::INTERNAL, "OnReadDone: reading error"));
+ this->terminate(grpc::Status(grpc::StatusCode::INTERNAL, "reading error"));
return;
}
try {
std::unique_ptr<grpc::Status> status = this->readRequest(this->request);
if (status != nullptr) {
- this->Finish(*status);
+ this->terminate(*status);
return;
}
} catch (std::runtime_error &e) {
- this->Finish(grpc::Status(grpc::StatusCode::INTERNAL, e.what()));
+ this->terminate(grpc::Status(grpc::StatusCode::INTERNAL, e.what()));
return;
}
this->StartRead(&this->request);
}
+} // namespace reactor
} // namespace network
} // namespace comm
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 1, 1:16 AM (15 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2603121
Default Alt Text
D3512.diff (4 KB)
Attached To
Mode
D3512: [services] Backup - Add server reactor base classes - read reactor
Attached
Detach File
Event Timeline
Log In to Comment