Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3350529
D3788.id12041.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D3788.id12041.diff
View Options
diff --git a/services/blob/CMakeLists.txt b/services/blob/CMakeLists.txt
--- a/services/blob/CMakeLists.txt
+++ b/services/blob/CMakeLists.txt
@@ -52,6 +52,7 @@
include_directories(
./src
./src/DatabaseEntities
+ ./src/Reactors/
./src/Reactors/server
./src/Reactors/server/base-reactors
./_generated
diff --git a/services/blob/src/Reactors/BaseReactor.h b/services/blob/src/Reactors/BaseReactor.h
new file mode 100644
--- /dev/null
+++ b/services/blob/src/Reactors/BaseReactor.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#include "ReactorUtility.h"
+
+#include <grpcpp/grpcpp.h>
+
+#include <memory>
+
+namespace comm {
+namespace network {
+namespace reactor {
+
+class BaseReactor {
+public:
+ virtual std::shared_ptr<ReactorUtility> getUtility() = 0;
+ virtual void terminate(const grpc::Status &status) = 0;
+ virtual void validate() = 0;
+ virtual void doneCallback() = 0;
+ virtual void terminateCallback() = 0;
+};
+
+} // namespace reactor
+} // namespace network
+} // namespace comm
diff --git a/services/blob/src/Reactors/ReactorUtility.h b/services/blob/src/Reactors/ReactorUtility.h
new file mode 100644
--- /dev/null
+++ b/services/blob/src/Reactors/ReactorUtility.h
@@ -0,0 +1,39 @@
+#pragma once
+
+#include <grpcpp/grpcpp.h>
+
+#include <atomic>
+#include <mutex>
+
+namespace comm {
+namespace network {
+namespace reactor {
+
+enum class ReactorState {
+ NONE = 0,
+ RUNNING = 1,
+ TERMINATED = 2,
+ DONE = 3,
+};
+
+class ReactorUtility {
+private:
+ grpc::Status status = grpc::Status::OK;
+ std::mutex statusAccessMutex;
+
+public:
+ std::atomic<ReactorState> state = ReactorState::NONE;
+
+ grpc::Status getStatus() {
+ const std::unique_lock<std::mutex> lock(this->statusAccessMutex);
+ return this->status;
+ }
+ void setStatus(const grpc::Status &status) {
+ const std::unique_lock<std::mutex> lock(this->statusAccessMutex);
+ this->status = status;
+ }
+};
+
+} // namespace reactor
+} // namespace network
+} // namespace comm
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 10:57 PM (11 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2566911
Default Alt Text
D3788.id12041.diff (1 KB)
Attached To
Mode
D3788: [services] Blob - Pull more mutual code from base reactors - Add base reactor
Attached
Detach File
Event Timeline
Log In to Comment