#pragma once #include #include #include "rediska/common/enums.hpp" #include "rediska/common/types.hpp" #include "rediska/common/MessageArguments.hpp" #include #include // for ServerAsyncStreamingInterface completeness // TODO: get rid of forward declaration somehow maybe struct BaseRequestManager; struct RequestEvent { BaseRequestManager& manager; }; // This just leaves the responder for you to delete. struct FinishEvent { std::unique_ptr responder; }; using EventVariant = std::variant; struct QueueMessage { CacheValueId type; CacheKey key; OperationId operation; MessageArguments arguments; std::unique_ptr responder; template void respond(ResponseT response) { if (auto* writer = dynamic_cast*>(responder.get())) { writer->Finish(response, grpc::Status::OK, std::make_unique(FinishEvent { std::move(responder) }).release()); responder = nullptr; } else { throw std::runtime_error("Invalid responder type in QueueMessage::respond"); } } };