Skip to content

Commit 6e86b68

Browse files
potat-devL0rdLizard
andcommitted
Final code cleanup
Co-authored-by: L0rdLizard <WarriorXKZ@gmail.com>
1 parent fa5a4d8 commit 6e86b68

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+84
-325
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ CPMAddPackage(
3030
OPTIONS "BOOST_ENABLE_CMAKE ON" "BOOST_INCLUDE_LIBRARIES container\\\;asio" # Note the escapes!
3131
)
3232

33-
find_package(SqliteOrm REQUIRED)
3433
find_package(argparse REQUIRED)
3534
find_package(nlohmann_json REQUIRED)
3635

conandata.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33

44
requirements:
55
- "nlohmann_json/3.11.3"
6-
- "argparse/3.0"
7-
- "sqlite_orm/1.8.2"
6+
- "argparse/3.0"

examples/client.cpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
1-
//
2-
// Created by Serge on 07.03.2024.
3-
//
4-
5-
61
#include <iostream>
72
#include <boost/asio.hpp>
83

94

105
#include "client/STIPClient.h"
6+
117
using namespace STIP;
8+
129
#include <csignal>
1310

1411
int main() {
1512
try {
16-
1713
boost::asio::io_context io_context;
1814

1915
udp::resolver resolver(io_context);
2016
udp::endpoint server_endpoint = *resolver.resolve(udp::v4(), "localhost", "12345").begin();
2117

22-
2318
udp::socket socket(io_context);
2419
socket.open(udp::v4());
2520

@@ -28,21 +23,13 @@ int main() {
2823

2924
Connection *connection = client.connect(server_endpoint, 1000, 3);
3025
std::cout << "Connection accepted\n\n" << std::endl;
31-
// connection->send("Hello, I'm Ilya");
32-
33-
// uint32_t result = connection->pingVersion();
34-
// std::cout << "Ping result: " << result << std::endl;
3526

3627
std::string message = "Hello, I'm Ilya";
3728
connection->sendMessage(message);
3829

3930
ReceiveMessageSession *received = connection->receiveMessage();
4031
std::cout << "Received message: " << received->getDataAsString() << std::endl;
4132

42-
43-
44-
45-
// io_context.run();
4633
} catch (std::exception &e) {
4734
std::cerr << "Exception: " << e.what() << std::endl;
4835
}

examples/server.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
//
2-
// Created by Serge on 07.03.2024.
3-
//
4-
51
#include "protocol/STIP.h"
62
#include "server/STIPServer.h"
73
#include "protocol/Connection.h"

src/DataModel/Client.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
//
2-
// Created by Potato on 12.04.24.
3-
//
4-
51
#ifndef RABBIT_USER_H
62
#define RABBIT_USER_H
73

src/DataModel/Message.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
//
2-
// Created by Potato on 12.04.24.
3-
//
4-
51
#ifndef RABBIT_MESSAGE_H
62
#define RABBIT_MESSAGE_H
73

src/DataModel/Task.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
//
2-
// Created by Serge on 26.03.2024.
3-
//
4-
51
#ifndef RABBIT_TASKS_H
62
#define RABBIT_TASKS_H
73

src/DataModel/TaskRequest.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
//
2-
// Created by Potato on 11.04.24.
3-
//
4-
51
#ifndef RABBIT_TASKREQUEST_H
62
#define RABBIT_TASKREQUEST_H
73

src/DataModel/TaskResult.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
//
2-
// Created by Potato on 11.04.24.
3-
//
4-
51
#ifndef RABBIT_TASKRESULT_H
62
#define RABBIT_TASKRESULT_H
73

src/DataModel/Worker.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
//
2-
// Created by Potato on 12.04.24.
3-
//
4-
51
#ifndef RABBIT_WORKER_H
62
#define RABBIT_WORKER_H
73

src/client/STIPClient.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
//
2-
// Created by Serge on 07.03.2024.
3-
//
4-
5-
61
#include "STIPClient.h"
72
#include <future>
83
#include <chrono>

src/client/STIPClient.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
//
2-
// Created by Serge on 07.03.2024.
3-
//
4-
51
#ifndef RABBIT_STIPCLIENT_H
62
#define RABBIT_STIPCLIENT_H
73

src/cmd/clientMain.cpp

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
//
2-
// Created by Serge on 23.03.2024.
3-
//
4-
51
#include "rabbitCore/client/RabbitClient.h"
62
#include "DataModel/TaskRequest.h"
73
#include <argparse/argparse.hpp>
@@ -130,7 +126,6 @@ void *senderThread(void *arg) {
130126

131127
std::string requestFunc;
132128
std::string requestParams;
133-
// enter cores
134129
int cores;
135130
std::cout << "Enter cores count:" << std::endl;
136131
std::cout << "> ";
@@ -153,27 +148,6 @@ void *senderThread(void *arg) {
153148
requestFunc = "matrixMultiplication";
154149
break;
155150

156-
// int t, tasksCount, delay;
157-
// std::cout << "Enter tasks count:" << std::endl;
158-
// std::cout << "> ";
159-
// std::cin >> tasksCount;
160-
// std::cout << "Enter delay between tasks:" << std::endl;
161-
// std::cout << "> ";
162-
// std::cin >> delay;
163-
// for (t = 0; t < tasksCount; t++) {
164-
// json data;
165-
// data["a"] = rand() % 100;
166-
// data["b"] = rand() % 100;
167-
// int taskId = rand();
168-
// client->sendTask(TaskRequest{std::to_string(taskId), "simpleMath", data.dump(), cores});
169-
// std::cout << "Task " << taskId << " sent" << std::endl;
170-
// std::this_thread::sleep_for(std::chrono::milliseconds(delay));
171-
// }
172-
//
173-
// requestParams = promptMatrixDeterminantTask();
174-
// requestFunc = "determinant";
175-
// break;
176-
177151
case 0:
178152
return nullptr;
179153

@@ -193,6 +167,9 @@ void *senderThread(void *arg) {
193167

194168
int main(int argc, const char *argv[]) {
195169
argparse::ArgumentParser program("RabbitClient");
170+
program.add_description("RabbitClient");
171+
program.add_epilog("RabbitClient is a client for Rabbit project");
172+
196173
program.add_argument("-i", "--id")
197174
.help("Worker ID")
198175
.default_value("1234");
@@ -203,8 +180,6 @@ int main(int argc, const char *argv[]) {
203180
.help("Server Port")
204181
.default_value(12345)
205182
.action([](const std::string &value) { return std::stoi(value); });
206-
program.add_description("RabbitClient");
207-
program.add_epilog("RabbitClient is a client for Rabbit project");
208183

209184
try {
210185
program.parse_args(argc, argv);

src/cmd/serverMain.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
//
2-
// Created by Serge on 23.03.2024.
3-
//
4-
51
#include "rabbitCore/server/RabbitServer.h"
62
#include <argparse/argparse.hpp>
73
#include <iostream>
84

95
int main(int argc, const char *argv[]) {
106
argparse::ArgumentParser program("RabbitServer");
7+
program.add_description("RabbitServer");
8+
program.add_epilog("RabbitServer is a server for Rabbit project");
9+
1110
program.add_argument("-p", "--port")
1211
.help("Port to listen")
1312
.default_value(12345)
1413
.action([](const std::string &value) { return std::stoi(value); });
15-
program.add_description("RabbitServer");
16-
program.add_epilog("RabbitServer is a server for Rabbit project");
1714

1815
try {
1916
program.parse_args(argc, argv);
@@ -25,7 +22,9 @@ int main(int argc, const char *argv[]) {
2522

2623
int port = program.get<int>("--port");
2724
RabbitServer server(port);
25+
2826
server.init();
2927
server.startPolling();
28+
3029
return 0;
3130
}

src/cmd/workerMain.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
//
2-
// Created by Serge on 23.03.2024.
3-
//
4-
51
#include "rabbitCore/worker/RabbitWorker.h"
62
#include <argparse/argparse.hpp>
73
#include <iostream>
84

95
int main(int argc, const char *argv[]) {
106
argparse::ArgumentParser program("RabbitWorker");
7+
program.add_description("RabbitWorker");
8+
program.add_epilog("RabbitWorker is a worker for Rabbit project");
9+
1110
program.add_argument("-i", "--id")
1211
.help("Worker ID")
1312
.default_value("1234");
@@ -22,8 +21,6 @@ int main(int argc, const char *argv[]) {
2221
.help("Max cores")
2322
.default_value(4)
2423
.action([](const std::string &value) { return std::stoi(value); });
25-
program.add_description("RabbitWorker");
26-
program.add_epilog("RabbitWorker is a worker for Rabbit project");
2724

2825
try {
2926
program.parse_args(argc, argv);
@@ -37,9 +34,12 @@ int main(int argc, const char *argv[]) {
3734
auto host = program.get<std::string>("--host");
3835
int port = program.get<int>("--port");
3936
int cores = program.get<int>("--cores");
37+
4038
RabbitWorker worker(id, host, port, cores);
4139
worker.init();
40+
4241
std::cout << "Worker [" << id << "] started on [" << host << ":" << port << "]" << std::endl;
4342
worker.startPolling();
43+
4444
return 0;
4545
}

src/protocol/Commands.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
//
2-
// Created by Serge on 12.04.2024.
3-
//
4-
51
#ifndef RABBIT_COMMANDS_H
62
#define RABBIT_COMMANDS_H
73
#include <ostream>

src/protocol/Connection.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
//
2-
// Created by Serge on 08.03.2024.
3-
//
4-
51
#include "Connection.h"
62
#include "protocol/STIP.h"
73
#include "protocol/Session.h"

src/protocol/Connection.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
//
2-
// Created by Serge on 08.03.2024.
3-
//
4-
51
#ifndef RABBIT_CONNECTION_H
62
#define RABBIT_CONNECTION_H
73

src/protocol/STIP.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
//
2-
// Created by Serge on 07.03.2024.
3-
//
4-
51
#ifndef RABBIT_STIP_BASE_H
62
#define RABBIT_STIP_BASE_H
73

src/protocol/STIPVersion.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
//
2-
// Created by Serge on 17.03.2024.
3-
//
4-
51
#ifndef RABBIT_CLIENTVERSION_H
62
#define RABBIT_CLIENTVERSION_H
73

src/protocol/Session.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
//
2-
// Created by Serge on 16.03.2024.
3-
//
4-
51
#include "Session.h"
62
#include <boost/asio.hpp>
73

src/protocol/Session.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
//
2-
// Created by Serge on 16.03.2024.
3-
//
4-
51
#ifndef RABBIT_SESSION_H
62
#define RABBIT_SESSION_H
73

src/protocol/SessionKiller.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
//
2-
// Created by Serge on 11.04.2024.
3-
//
4-
51
#include "SessionKiller.h"
62

73
#include <utility>

src/protocol/SessionKiller.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
//
2-
// Created by Serge on 11.04.2024.
3-
//
4-
51
#ifndef RABBIT_SESSIONKILLER_H
62
#define RABBIT_SESSIONKILLER_H
73

0 commit comments

Comments
 (0)