Skip to content

Commit

Permalink
[sdk] Support string-based arguments to process resources
Browse files Browse the repository at this point in the history
  • Loading branch information
mcopik committed Aug 10, 2023
1 parent 9f89cc6 commit 132a6a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion sdk/include/praas/sdk/praas.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ namespace praas::sdk {
bool create_application(const std::string& application, const std::string& cloud_resource_name);

std::optional<Process> create_process(
const std::string& application, const std::string& process_name, int vcpus, int memory
const std::string& application, const std::string& process_name, std::string vcpus,
std::string memory
);

ControlPlaneInvocationResult invoke(
Expand Down
8 changes: 5 additions & 3 deletions sdk/src/praas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ namespace praas::sdk {
}

std::optional<Process> PraaS::create_process(
const std::string& application, const std::string& process_name, int vcpus, int memory
const std::string& application, const std::string& process_name, std::string vcpus,
std::string memory
)
{
auto req = drogon::HttpRequest::newHttpRequest();
req->setMethod(drogon::Put);
req->setPath(fmt::format("/apps/{}/processes/{}", application, process_name));
req->setParameter("vcpus", std::to_string(vcpus));
req->setParameter("memory", std::to_string(memory));
req->setParameter("vcpus", vcpus);
req->setParameter("memory", memory);

std::promise<std::optional<Process>> p;

Expand All @@ -65,6 +66,7 @@ namespace praas::sdk {
auto port = json_obj["connection"]["port"].asInt();
p.set_value(Process{ip_addr, port, true});
} else {
std::cerr << *response->getJsonObject() << std::endl;
p.set_value(std::nullopt);
}
}
Expand Down

0 comments on commit 132a6a6

Please sign in to comment.