Skip to content

Commit

Permalink
Removed the admin library and made the provider manage a single resou…
Browse files Browse the repository at this point in the history
…rce.
  • Loading branch information
mdorier committed Nov 22, 2023
1 parent 8c19128 commit fd143f3
Show file tree
Hide file tree
Showing 31 changed files with 145 additions and 1,008 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ endif ()
find_package (PkgConfig REQUIRED)
# search fo thallium
find_package (thallium REQUIRED)
# search for uuid
pkg_check_modules (uuid REQUIRED IMPORTED_TARGET uuid)
# search for nlohmann/json
find_package (nlohmann_json REQUIRED)
# search for TCLAP
Expand Down
3 changes: 0 additions & 3 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
add_executable (example-server ${CMAKE_CURRENT_SOURCE_DIR}/server.cpp)
target_link_libraries (example-server fmt::fmt spdlog::spdlog alpha-server)

add_executable (example-admin ${CMAKE_CURRENT_SOURCE_DIR}/admin.cpp)
target_link_libraries (example-admin fmt::fmt spdlog::spdlog alpha-admin)

add_executable (example-client ${CMAKE_CURRENT_SOURCE_DIR}/client.cpp)
target_link_libraries (example-client fmt::fmt spdlog::spdlog alpha-client)
100 changes: 0 additions & 100 deletions examples/admin.cpp

This file was deleted.

10 changes: 4 additions & 6 deletions examples/bedrock-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
"name": "my-alpha-provider",
"provider_id": 42,
"config": {
"resources": [
{
"type": "dummy",
"config": {}
}
]
"resource": {
"type": "dummy",
"config": {}
}
}
}
]
Expand Down
7 changes: 1 addition & 6 deletions examples/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ namespace tl = thallium;

static std::string g_address;
static std::string g_protocol;
static std::string g_resource;
static unsigned g_provider_id;
static std::string g_log_level = "info";

Expand All @@ -32,8 +31,7 @@ int main(int argc, char** argv) {

// Open the Resource "myresource" from provider 0
alpha::ResourceHandle resource =
client.makeResourceHandle(g_address, g_provider_id,
alpha::UUID::from_string(g_resource.c_str()));
client.makeResourceHandle(g_address, g_provider_id);

int32_t result;
resource.computeSum(32, 54, &result);
Expand All @@ -51,16 +49,13 @@ void parse_command_line(int argc, char** argv) {
TCLAP::CmdLine cmd("Alpha client", ' ', "0.1");
TCLAP::ValueArg<std::string> addressArg("a","address","Address or server", true,"","string");
TCLAP::ValueArg<unsigned> providerArg("p", "provider", "Provider id to contact (default 0)", false, 0, "int");
TCLAP::ValueArg<std::string> resourceArg("r","resource","Resource id", true, alpha::UUID().to_string(),"string");
TCLAP::ValueArg<std::string> logLevel("v","verbose", "Log level (trace, debug, info, warning, error, critical, off)", false, "info", "string");
cmd.add(addressArg);
cmd.add(providerArg);
cmd.add(resourceArg);
cmd.add(logLevel);
cmd.parse(argc, argv);
g_address = addressArg.getValue();
g_provider_id = providerArg.getValue();
g_resource = resourceArg.getValue();
g_log_level = logLevel.getValue();
g_protocol = g_address.substr(0, g_address.find(":"));
} catch(TCLAP::ArgException &e) {
Expand Down
15 changes: 11 additions & 4 deletions examples/server.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* (C) 2020 The University of Chicago
*
*
* See COPYRIGHT in top-level directory.
*/
#include <alpha/Provider.hpp>
Expand All @@ -10,7 +10,6 @@
#include <tclap/CmdLine.h>

namespace tl = thallium;
namespace snt = alpha;

static std::string g_address = "na+sm";
static unsigned g_num_providers = 1;
Expand All @@ -25,9 +24,17 @@ int main(int argc, char** argv) {
spdlog::set_level(spdlog::level::from_str(g_log_level));
tl::engine engine(g_address, THALLIUM_SERVER_MODE, g_use_progress_thread, g_num_threads);
engine.enable_remote_shutdown();
std::vector<snt::Provider> providers;
const auto provider_config = R"(
{
"resource": {
"type": "dummy",
"config": {}
}
}
)";
std::vector<alpha::Provider> providers;
for(unsigned i=0 ; i < g_num_providers; i++) {
providers.emplace_back(engine, i);
providers.emplace_back(engine, i, provider_config);
}
spdlog::info("Server running at address {}", (std::string)engine.self());
engine.wait_for_finalize();
Expand Down
Loading

0 comments on commit fd143f3

Please sign in to comment.