Skip to content

Commit

Permalink
broker: add config.get RPC
Browse files Browse the repository at this point in the history
Problem: the broker offers no way for the parsed TOML config
object to be accessed outside of the broker and its loadable
modules.

Add a 'config.get' RPC that allows the current object to be fetched.
  • Loading branch information
garlick committed Feb 25, 2022
1 parent 6da7da4 commit ae70caf
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/broker/brokercfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,32 @@ static void reload_cb (flux_t *h,
flux_log_error (h, "reload: flux_respond_error");
}

static void get_cb (flux_t *h,
flux_msg_handler_t *mh,
const flux_msg_t *msg,
void *arg)
{
const char *errmsg = NULL;
flux_conf_error_t error;
json_t *o;

if (flux_request_decode (msg, NULL, NULL) < 0)
goto error;
if (flux_conf_unpack (flux_get_conf (h), &error, "o", &o) < 0) {
errmsg = error.errbuf;
goto error;
}
if (flux_respond_pack (h, msg, "O", o) < 0)
flux_log_error (h, "error responding to config.get request");
return;
error:
if (flux_respond_error (h, msg, errno, errmsg) < 0)
flux_log_error (h, "error responding to config.get request");
}

static const struct flux_msg_handler_spec htab[] = {
{ FLUX_MSGTYPE_REQUEST, "config.reload", reload_cb, 0 },
{ FLUX_MSGTYPE_REQUEST, "config.get", get_cb, 0 },
FLUX_MSGHANDLER_TABLE_END,
};

Expand Down

0 comments on commit ae70caf

Please sign in to comment.