diff --git a/services/backup/src/Reactors/BaseReactor.h b/services/backup/src/Reactors/BaseReactor.h new file mode 100644 index 000000000..76e16e365 --- /dev/null +++ b/services/backup/src/Reactors/BaseReactor.h @@ -0,0 +1,24 @@ +#pragma once + +#include "ReactorUtility.h" + +#include + +#include + +namespace comm { +namespace network { +namespace reactor { + +class BaseReactor { +public: + virtual std::shared_ptr 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/backup/src/Reactors/ReactorUtility.h b/services/backup/src/Reactors/ReactorUtility.h new file mode 100644 index 000000000..c3ce61f00 --- /dev/null +++ b/services/backup/src/Reactors/ReactorUtility.h @@ -0,0 +1,39 @@ +#pragma once + +#include + +#include +#include + +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 state = ReactorState::NONE; + + grpc::Status getStatus() { + const std::unique_lock lock(this->statusAccessMutex); + return this->status; + } + void setStatus(const grpc::Status &status) { + const std::unique_lock lock(this->statusAccessMutex); + this->status = status; + } +}; + +} // namespace reactor +} // namespace network +} // namespace comm