[style] main namespace renamed to SCORE
based on new suggested project name
This commit is contained in:
parent
46cf56196e
commit
e0295f21b5
@ -3,7 +3,7 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "export.h"
|
||||
namespace cloud_point_rpc {
|
||||
namespace score {
|
||||
|
||||
/**
|
||||
* @brief Runs the CLI client.
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
#include <vector>
|
||||
#include <yaml-cpp/yaml.h>
|
||||
|
||||
namespace cloud_point_rpc {
|
||||
namespace score {
|
||||
|
||||
struct ServerConfig {
|
||||
std::string ip;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
#include <jsonrpccxx/client.hpp>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <vector>
|
||||
namespace cloud_point_rpc {
|
||||
namespace score {
|
||||
|
||||
class RpcClient : public jsonrpccxx::JsonRpcClient {
|
||||
public:
|
||||
|
||||
@ -16,7 +16,7 @@ struct rpc_string {
|
||||
};
|
||||
}
|
||||
|
||||
namespace cloud_point_rpc {
|
||||
namespace score {
|
||||
|
||||
class CRPC_EXPORT RpcServer {
|
||||
public:
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
namespace cloud_point_rpc {
|
||||
namespace score {
|
||||
|
||||
template <typename T>
|
||||
concept NumericType = requires(T param) {
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
#include "cloud_point_rpc/config.hpp"
|
||||
#include <vector>
|
||||
#include "export.h"
|
||||
namespace cloud_point_rpc {
|
||||
namespace score {
|
||||
|
||||
class CRPC_EXPORT Service {
|
||||
public:
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
#include <glog/logging.h>
|
||||
#include <string>
|
||||
#include "export.h"
|
||||
namespace cloud_point_rpc {
|
||||
namespace score {
|
||||
/**
|
||||
* TCPConnector main purpose is to implement jsonrpccxx::IClientConnector Send
|
||||
* method As an internal implementation, TCPConnector adds to the beginning of
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
#include <asio.hpp>
|
||||
#include <cloud_point_rpc/serialize.hpp>
|
||||
#include <glog/logging.h>
|
||||
namespace cloud_point_rpc {
|
||||
namespace score {
|
||||
|
||||
static inline std::string tcp_read(asio::ip::tcp::socket &socket,
|
||||
std::string_view prefix) {
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
#include "export.h"
|
||||
#include <list>
|
||||
#include <ranges>
|
||||
namespace cloud_point_rpc {
|
||||
namespace score {
|
||||
|
||||
class CRPC_EXPORT TcpServer {
|
||||
public:
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
#include <glog/logging.h>
|
||||
#include <string>
|
||||
|
||||
namespace cloud_point_rpc {
|
||||
namespace score {
|
||||
|
||||
void print_menu(std::ostream &output) {
|
||||
output << "\n=== Cloud Point RPC CLI ===" << std::endl;
|
||||
|
||||
@ -24,8 +24,8 @@ int main(int argc, char *argv[]) {
|
||||
f.close();
|
||||
|
||||
try {
|
||||
auto config = cloud_point_rpc::ConfigLoader::load(config_path);
|
||||
return cloud_point_rpc::run_cli(std::cin, std::cout, config.server.ip,
|
||||
auto config = score::ConfigLoader::load(config_path);
|
||||
return score::run_cli(std::cin, std::cout, config.server.ip,
|
||||
config.server.port);
|
||||
} catch (const std::exception &e) {
|
||||
std::cerr << "Failed to start CLI: " << e.what() << std::endl;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
#include <glog/logging.h>
|
||||
using json = nlohmann::json;
|
||||
|
||||
namespace cloud_point_rpc {
|
||||
namespace score {
|
||||
|
||||
namespace {
|
||||
json create_error(int code, const std::string &message,
|
||||
|
||||
@ -9,8 +9,8 @@
|
||||
#include <list>
|
||||
|
||||
static std::list<std::unique_ptr<rpc_string>> gc;
|
||||
cloud_point_rpc::RpcServer rpc_server;
|
||||
std::unique_ptr<cloud_point_rpc::TcpServer> server = nullptr;
|
||||
score::RpcServer rpc_server;
|
||||
std::unique_ptr<score::TcpServer> server = nullptr;
|
||||
|
||||
extern "C" {
|
||||
|
||||
@ -40,10 +40,10 @@ void crpc_init(const char* config_path) {
|
||||
LOG(INFO) << "config_path was not provided";
|
||||
}
|
||||
try {
|
||||
auto config = cloud_point_rpc::ConfigLoader::load(config_path);
|
||||
auto config = score::ConfigLoader::load(config_path);
|
||||
LOG(INFO) << "Loaded config from " << config_path;
|
||||
|
||||
server = std::make_unique<cloud_point_rpc::TcpServer>(config.server.ip, config.server.port,
|
||||
server = std::make_unique<score::TcpServer>(config.server.ip, config.server.port,
|
||||
[&](const std::string &request) {
|
||||
return rpc_server.process(
|
||||
request);
|
||||
|
||||
@ -20,12 +20,12 @@ int main(int argc, char *argv[]) {
|
||||
LOG(INFO) << "Starting Cloud Point RPC Server (Test Mock)...";
|
||||
|
||||
try {
|
||||
auto config = cloud_point_rpc::ConfigLoader::load(config_path);
|
||||
auto config = score::ConfigLoader::load(config_path);
|
||||
LOG(INFO) << "Loaded config from " << config_path;
|
||||
|
||||
// Inject test data into service
|
||||
cloud_point_rpc::Service service(config.test_data);
|
||||
cloud_point_rpc::RpcServer rpc_server;
|
||||
score::Service service(config.test_data);
|
||||
score::RpcServer rpc_server;
|
||||
|
||||
rpc_server.register_method("get-intrinsic-params", [&](const json &) {
|
||||
return service.get_intrinsic_params();
|
||||
@ -39,7 +39,7 @@ int main(int argc, char *argv[]) {
|
||||
return service.get_cloud_point();
|
||||
});
|
||||
|
||||
cloud_point_rpc::TcpServer server(config.server.ip, config.server.port,
|
||||
score::TcpServer server(config.server.ip, config.server.port,
|
||||
[&](const std::string &request) {
|
||||
return rpc_server.process(
|
||||
request);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#include "cloud_point_rpc/service.hpp"
|
||||
|
||||
namespace cloud_point_rpc {
|
||||
namespace score {
|
||||
|
||||
Service::Service(const TestData &data) : data_(data) {}
|
||||
|
||||
|
||||
@ -121,7 +121,7 @@ class TestThread {
|
||||
calls_queue = std::queue<std::string>();
|
||||
methods.clear();
|
||||
state.store(true, std::memory_order_relaxed);
|
||||
server = cloud_point_rpc::RpcServer();
|
||||
server = score::RpcServer();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -131,7 +131,7 @@ class TestThread {
|
||||
std::set<std::string> methods{};
|
||||
std::jthread thr;
|
||||
std::mutex mtx;
|
||||
cloud_point_rpc::RpcServer server;
|
||||
score::RpcServer server;
|
||||
std::chrono::duration<int64_t, std::milli> thr_sleep{50};
|
||||
} test;
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
#include "cloud_point_rpc/rpc_server.hpp"
|
||||
#include "cloud_point_rpc/tcp_server.hpp"
|
||||
|
||||
using namespace cloud_point_rpc;
|
||||
using namespace score;
|
||||
|
||||
class CliTest : public ::testing::Test {
|
||||
public:
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
#include <fstream>
|
||||
|
||||
using namespace cloud_point_rpc;
|
||||
using namespace score;
|
||||
|
||||
class IntegrationTest : public ::testing::Test {
|
||||
protected:
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
#include <vector>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using namespace cloud_point_rpc;
|
||||
using namespace score;
|
||||
|
||||
class RpcServerTest : public ::testing::Test {
|
||||
protected:
|
||||
|
||||
@ -15,11 +15,11 @@ class TcpTest : public ::testing::Test {
|
||||
|
||||
protected:
|
||||
void SetUp() override {
|
||||
server_ = std::make_unique<cloud_point_rpc::TcpServer>(
|
||||
server_ = std::make_unique<score::TcpServer>(
|
||||
"127.0.0.1", 12345, [this](const std::string &request) {
|
||||
EXPECT_EQ(request, expected_);
|
||||
std::string msg = "Echo: " + request;
|
||||
auto v = cloud_point_rpc::serialize(msg.length());
|
||||
auto v = score::serialize(msg.length());
|
||||
std::string res(v.begin(), v.end());
|
||||
res += msg;
|
||||
return res;
|
||||
@ -33,19 +33,19 @@ class TcpTest : public ::testing::Test {
|
||||
}
|
||||
|
||||
std::string expected_;
|
||||
std::unique_ptr<cloud_point_rpc::TcpServer> server_;
|
||||
std::unique_ptr<score::TcpServer> server_;
|
||||
};
|
||||
|
||||
TEST(SerializeTest, Base) {
|
||||
uint64_t value{123};
|
||||
auto res = cloud_point_rpc::serialize(value);
|
||||
EXPECT_EQ(value, cloud_point_rpc::deserialize<uint64_t>(res));
|
||||
auto res = score::serialize(value);
|
||||
EXPECT_EQ(value, score::deserialize<uint64_t>(res));
|
||||
}
|
||||
|
||||
TEST_F(TcpTest, EchoTest) {
|
||||
constexpr std::string_view msg = "Hello, TCP Server!";
|
||||
ExpectedResponse(msg.data());
|
||||
cloud_point_rpc::TCPConnector connector("127.0.0.1", 12345);
|
||||
score::TCPConnector connector("127.0.0.1", 12345);
|
||||
auto res = connector.Send(msg.data());
|
||||
}
|
||||
|
||||
@ -53,6 +53,6 @@ TEST_F(TcpTest, HugeBuffer) {
|
||||
static constexpr uint64_t w = 1280, h = 720, c = 3;
|
||||
std::string data(w * h * c, 77);
|
||||
ExpectedResponse(data);
|
||||
cloud_point_rpc::TCPConnector connector("127.0.0.1", 12345);
|
||||
score::TCPConnector connector("127.0.0.1", 12345);
|
||||
auto res = connector.Send(data);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user