Skip to content

Commit

Permalink
[sdk] Add configuration of processor resources for invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
mcopik committed Oct 21, 2024
1 parent bfb3ca7 commit cb9d202
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
8 changes: 6 additions & 2 deletions sdk/include/praas/sdk/praas.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@ namespace praas::sdk {
ControlPlaneInvocationResult invoke(
const std::string& app_name, const std::string& function_name,
const std::string& invocation_data,
std::optional<std::string> process_name = std::nullopt
std::optional<std::string> process_name = std::nullopt,
std::optional<std::string> vcpus = std::nullopt,
std::optional<std::string> memory = std::nullopt
);

std::future<ControlPlaneInvocationResult> invoke_async(
const std::string& app_name, const std::string& function_name,
const std::string& invocation_data,
std::optional<std::string> process_name = std::nullopt
std::optional<std::string> process_name = std::nullopt,
std::optional<std::string> vcpus = std::nullopt,
std::optional<std::string> memory = std::nullopt
);

std::tuple<bool, std::string> swap_process(const Process& process);
Expand Down
19 changes: 16 additions & 3 deletions sdk/src/praas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,22 @@ namespace praas::sdk {

ControlPlaneInvocationResult PraaS::invoke(
const std::string& app_name, const std::string& function_name,
const std::string& invocation_data, std::optional<std::string> process_name
const std::string& invocation_data, std::optional<std::string> process_name,
std::optional<std::string> vcpus, std::optional<std::string> memory
)
{
return invoke_async(app_name, function_name, invocation_data, std::move(process_name)).get();
return invoke_async(
app_name, function_name, invocation_data,
std::move(process_name),
std::move(vcpus),
std::move(memory)
).get();
}

std::future<ControlPlaneInvocationResult> PraaS::invoke_async(
const std::string& app_name, const std::string& function_name,
const std::string& invocation_data, std::optional<std::string> process_name
const std::string& invocation_data, std::optional<std::string> process_name,
std::optional<std::string> vcpus, std::optional<std::string> memory
)
{
// We need a shared_ptr because we cannot move it to the lambda later
Expand All @@ -223,6 +230,12 @@ namespace praas::sdk {
if(process_name.has_value()) {
req->setParameter("process_name", process_name.value());
}
if(vcpus.has_value()) {
req->setParameter("vcpus", vcpus.value());
}
if(memory.has_value()) {
req->setParameter("memory", memory.value());
}
req->setContentTypeCode(drogon::ContentType::CT_APPLICATION_JSON);

auto http_client = _get_client();
Expand Down

0 comments on commit cb9d202

Please sign in to comment.