Draft
Conversation
Written by ChatGPT: https://chatgpt.com/share/672b9656-e62c-8009-834f-ee360f67e96f This is to be reviewed and probably largely refactored. Still serves as good start
UsualSpec
commented
Nov 6, 2024
server++/server.cc
Outdated
Comment on lines
1
to
10
| #include <grpcpp/grpcpp.h> | ||
| #include <jsoncpp/json/json.h> | ||
| #include <fstream> | ||
| #include <iostream> | ||
| #include <memory> | ||
| #include <pqxx/pqxx> | ||
| #include <thread> | ||
| #include "CLI.h" | ||
| #include "CMeasurementApiServicer.h" | ||
| #include "PgConnectorFactory.h" |
Collaborator
Author
There was a problem hiding this comment.
Probably all should be in server.h
server++/server.cc
Outdated
|
|
||
| int main(int argc, char* argv[]) { | ||
| // Parse arguments | ||
| cxxopts::Options options("MeasurementServer", "Server for managing measurements via gRPC."); |
Collaborator
Author
There was a problem hiding this comment.
-> verify cxxopts validity. New dependency
server++/server.cc
Outdated
| ("interactive", "Start server in interactive mode", cxxopts::value<bool>()->default_value("false")); | ||
|
|
||
| auto result = options.parse(argc, argv); | ||
| std::string secretsFilePath = result["secrets"].as<std::string>(); |
server++/server.cc
Outdated
| configFile >> config; | ||
|
|
||
| // Start the server | ||
| serve(secrets, config, interactive); |
Collaborator
Author
There was a problem hiding this comment.
TODO: Validate that it is ok to just parse the interactive flag, not whole "args" as in python.
server++/CMeasurementApiServicer.cc
Outdated
| pbdef::api::msmtSettings CMeasurementApiServicer::getMsmtSttngsAndStart(const pbdef::api::clientRequest& request) { | ||
| pbdef::api::msmtSettings settings; | ||
| pqxx::work txn(*pgConn_); | ||
| pqxx::result r = txn.exec_params("SELECT setting_key, setting_value FROM measurement_settings WHERE client_uid = $1", request.uid()); |
Collaborator
Author
There was a problem hiding this comment.
No! there is no measurement_settings table!
| } | ||
|
|
||
| pbdef::api::nothing CMeasurementApiServicer::putStatusMsg(const pbdef::api::statusMessage& request) { | ||
| ClientManager cm; |
server++/CMeasurementApiServicer.cc
Outdated
|
|
||
| bool CMeasurementApiServicer::isValidMgmtClient(const pbdef::api::mgmtClientRequest& request) { | ||
| auto clientIt = allowedMgmtClients_.find(request.client_id()); | ||
| return clientIt != allowedMgmtClients_.end() && clientIt->second == request.client_secret(); |
server++/CMeasurementApiServicer.cc
Outdated
| } | ||
| txn.commit(); | ||
| logClientWasSeenNow(request.uid()); | ||
| return clients; |
Collaborator
Author
There was a problem hiding this comment.
Rewrite this in gRPC style
server++/CMeasurementApiServicer.cc
Outdated
|
|
||
| pbdef::api::srvResponse CMeasurementApiServicer::issueRequestToClient(const pbdef::api::mgmtRequest& request) { | ||
| ClientManager cm; | ||
| cm.issueRequestToClient(request.client_uid(), request); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Attention! This was written by ChatGPT: https://chatgpt.com/share/672b9656-e62c-8009-834f-ee360f67e96f This is to be reviewed and probably largely refactored. Still serves as good start