Skip to content

Commit

Permalink
Renaming.
Browse files Browse the repository at this point in the history
  • Loading branch information
linuscu committed Oct 27, 2024
1 parent 3a3b150 commit 86c3ddb
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 16 deletions.
6 changes: 3 additions & 3 deletions packages/network/include/network/NetworkInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace l::network {
bool NetworkStatus(std::string_view interfaceName);

template<class T>
void CreateRequestTemplate(
void CreateRequest(
std::string_view interfaceName,
std::string_view queryName,
std::string_view endpointString,
Expand All @@ -55,12 +55,12 @@ namespace l::network {
return chandler(success, args, request);
};
for (int i = 0; i < numMaxParallellRequestConnections; i++) {
network->CreateRequestTemplate(std::make_unique<l::network::Request<T>>(queryName, "", defaultResponseSize, handlerWrapped, timeout));
network->CreateRequest(std::make_unique<l::network::Request<T>>(queryName, "", defaultResponseSize, handlerWrapped, timeout));
}
}
else {
for (int i = 0; i < numMaxParallellRequestConnections; i++) {
network->CreateRequestTemplate(std::make_unique<l::network::Request<T>>(queryName, "", defaultResponseSize, nullptr, timeout));
network->CreateRequest(std::make_unique<l::network::Request<T>>(queryName, "", defaultResponseSize, nullptr, timeout));
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions packages/network/include/network/NetworkInterfaceWS.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,18 @@ namespace l::network {

bool NetworkStatus(std::string_view interfaceName);

template<class T>
void CreateWebSocketTemplate(
void CreateWebSocket(
std::string_view interfaceName,
std::string_view queryName,
std::string_view endpointString,
std::function<l::concurrency::RunnableResult(bool success, std::string_view queryArguments, l::network::Request<T>&)> handler = nullptr
std::function<l::concurrency::RunnableResult(bool success, std::string_view queryArguments, l::network::WebSocket&)> handler = nullptr
) {
auto network = mNetworkManager.lock();
if (network) {
auto it = mInterfaces.find(interfaceName.data());
if (it != mInterfaces.end()) {
it->second.AddEndpoint(queryName, endpointString);
network->CreateRequestTemplate(std::make_unique<l::network::Request<T>>(queryName, "", 0, handler));
network->CreateRequest(std::make_unique<l::network::WebSocket>(queryName, "", 0, handler));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/network/include/network/NetworkManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace l::network {
int32_t CompletedRequestCount();
void ToggleVerboseLogging();

bool CreateRequestTemplate(std::unique_ptr<ConnectionBase> request);
bool CreateRequest(std::unique_ptr<ConnectionBase> request);
bool PostQuery(std::string_view queryName,
std::string_view queryArguments,
int32_t maxTries = 3,
Expand Down
2 changes: 1 addition & 1 deletion packages/network/source/common/NetworkInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace l::network {

std::string queryName = interfaceName.data();
queryName += "Ping";
CreateRequestTemplate<std::stringstream>(interfaceName, queryName, "", 1, 5000, 3, pingHandler);
CreateRequest<std::stringstream>(interfaceName, queryName, "", 1, 5000, 3, pingHandler);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/network/source/common/NetworkManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ namespace l::network {
mJobManager->gDebugLogging = !mJobManager->gDebugLogging;
}

bool NetworkManager::CreateRequestTemplate(std::unique_ptr<ConnectionBase> request) {
bool NetworkManager::CreateRequest(std::unique_ptr<ConnectionBase> request) {
std::lock_guard lock(mConnectionsMutex);
mConnections.emplace_back(std::move(request));
return true;
Expand Down
2 changes: 1 addition & 1 deletion packages/network/tests/common/NetworkInterfaceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ TEST(NetworkInterface, Setup) {
};

networkInterface->CreateInterface("Telegram", "https", "api.telegram.org");
networkInterface->CreateRequestTemplate<std::stringstream>("Telegram", "TradeFlowBot1", query, 1, 2000, 5, telegramHandler);
networkInterface->CreateRequest<std::stringstream>("Telegram", "TradeFlowBot1", query, 1, 2000, 5, telegramHandler);

std::string args;
std::string message = "NetworkInterface tester app";
Expand Down
6 changes: 3 additions & 3 deletions packages/network/tests/common/NetworkManagerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ TEST(NetworkManager, Setup) {
}
);

networkManager->CreateRequestTemplate(std::move(request1));
networkManager->CreateRequestTemplate(std::move(request2));
networkManager->CreateRequest(std::move(request1));
networkManager->CreateRequest(std::move(request2));
networkManager->PostQuery("requestName", "user defined query id");
networkManager->PostQuery("requestName", "custom queries on predefined requests", 3, "https://httpbin.org/anything");

Expand Down Expand Up @@ -71,7 +71,7 @@ TEST(NetworkManager, Setup) {
return l::concurrency::RunnableResult::SUCCESS;
}
);
networkManager->CreateRequestTemplate(std::move(request3));
networkManager->CreateRequest(std::move(request3));
networkManager->PostQuery("TelegramBot", args, 3);
TEST_TRUE(networkManager->TotalRequestCount() == 3, "");
}
Expand Down
4 changes: 2 additions & 2 deletions packages/network/tests/common/NetworkWebSocketTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ TEST(NetworkWebSocket, Setup) {
};

networkInterfaceWS->CreateInterface("Websocket", "wss", "echo.websocket.org");
networkInterfaceWS->CreateWebSocketTemplate<std::stringstream>("Websocket", "wsstest", "", websocketHandler);
networkInterfaceWS->CreateWebSocket<std::stringstream>("Websocket", "wsstest", "", websocketHandler);
networkInterfaceWS->Connect("Websocket", "wsstest");

char buffer[1024];
Expand Down Expand Up @@ -73,7 +73,7 @@ TEST(NetworkWebSocket, Binance) {

networkInterfaceWS->CreateInterface("Binance", "wss", "testnet.binance.vision");
//networkInterfaceWS->CreateInterface("Binance", "wss", "stream.binance.com", 443);
networkInterfaceWS->CreateWebSocketTemplate<std::stringstream>("Binance", "binance", "ws", websocketHandler);
networkInterfaceWS->CreateWebSocket<std::stringstream>("Binance", "binance", "ws", websocketHandler);
networkInterfaceWS->Connect("Binance", "binance");

char buffer[1024];
Expand Down

0 comments on commit 86c3ddb

Please sign in to comment.