Skip to content

Commit

Permalink
reapi: add grow function to C API
Browse files Browse the repository at this point in the history
  • Loading branch information
milroy committed Dec 12, 2024
1 parent be826c4 commit ebf5d3f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
22 changes: 17 additions & 5 deletions resource/reapi/bindings/c/reapi_cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@ extern "C" int reapi_cli_update_allocate (reapi_cli_ctx_t *ctx,
return rc;
}

extern "C" int reapi_cli_grow (reapi_cli_ctx_t *ctx,
const char *R_subgraph)
{
if (!ctx || !ctx->rqt || !R_subgraph) {
errno = EINVAL;
return -1;
}
return reapi_cli_t::grow (ctx->rqt, R_subgraph)
}

extern "C" int reapi_cli_cancel (reapi_cli_ctx_t *ctx, const uint64_t jobid, bool noent_ok)
{
if (!ctx || !ctx->rqt) {
Expand Down Expand Up @@ -259,11 +269,13 @@ extern "C" const char *reapi_cli_get_err_msg (reapi_cli_ctx_t *ctx)
{
std::string err_buf = "";

if (ctx->rqt)
err_buf = ctx->rqt->get_resource_query_err_msg () + reapi_cli_t::get_err_message ()
+ ctx->err_msg;
else
err_buf = reapi_cli_t::get_err_message () + ctx->err_msg;
if (!ctx || !ctx->rqt) {
errno = EINVAL;
return "ERROR: REAPI context and/or rqt null \n";
}

err_buf = ctx->rqt->get_resource_query_err_msg () + reapi_cli_t::get_err_message ()
+ ctx->err_msg;

return strdup (err_buf.c_str ());
}
Expand Down
12 changes: 12 additions & 0 deletions resource/reapi/bindings/c/reapi_cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,18 @@ int reapi_cli_update_allocate (reapi_cli_ctx_t *ctx,
double *ov,
const char **R_out);

/*! Update the resource state with R.
*
* \param h Opaque handle. How it is used is an implementation
* detail. However, when it is used within a Flux's
* service module, it is expected to be a pointer
* to a flux_t object.
* \param R_subgraph R string
* \return 0 on success; -1 on error.
*/
int reapi_cli_grow (reapi_cli_ctx_t *ctx,
const char *R_subgraph);

/*! Cancel the allocation or reservation corresponding to jobid.
*
* \param ctx reapi_cli_ctx_t context object
Expand Down

0 comments on commit ebf5d3f

Please sign in to comment.