Skip to content

Commit

Permalink
libflux/event: rename event_encodef->event_pack
Browse files Browse the repository at this point in the history
Rename flux_event_encodef() to flux_event_pack()
per discussion in flux-framework#1094.

Update unit tests and users in libflux, libjsc,
wreck job module, wrexecd, and broker.
  • Loading branch information
garlick committed Jul 13, 2017
1 parent f206221 commit 5cea390
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 24 deletions.
10 changes: 5 additions & 5 deletions src/broker/shutdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ flux_msg_t *shutdown_vencode (double grace, int exitcode, int rank,

vsnprintf (reason, sizeof (reason), fmt, ap);

return flux_event_encodef ("shutdown", "{ s:s s:f s:i s:i }",
"reason", reason,
"grace", grace,
"rank", rank,
"exitcode", exitcode);
return flux_event_pack ("shutdown", "{ s:s s:f s:i s:i }",
"reason", reason,
"grace", grace,
"rank", rank,
"exitcode", exitcode);
}

flux_msg_t *shutdown_encode (double grace, int exitcode, int rank,
Expand Down
8 changes: 4 additions & 4 deletions src/common/libflux/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ flux_msg_t *flux_event_encode (const char *topic, const char *json_str)
return NULL;
}

static flux_msg_t *flux_event_vencodef (const char *topic,
const char *fmt, va_list ap)
static flux_msg_t *flux_event_vpack (const char *topic,
const char *fmt, va_list ap)
{
flux_msg_t *msg = flux_event_create (topic);
if (!msg)
Expand All @@ -151,13 +151,13 @@ static flux_msg_t *flux_event_vencodef (const char *topic,
return NULL;
}

flux_msg_t *flux_event_encodef (const char *topic, const char *fmt, ...)
flux_msg_t *flux_event_pack (const char *topic, const char *fmt, ...)
{
flux_msg_t *msg;
va_list ap;

va_start (ap, fmt);
msg = flux_event_vencodef (topic, fmt, ap);
msg = flux_event_vpack (topic, fmt, ap);
va_end (ap);
return msg;
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/libflux/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ flux_msg_t *flux_event_encode (const char *topic, const char *json_str);
* jansson pack style variable arguments for encoding the JSON object
* payload directly. Returns message or NULL on failure with errno set.
*/
flux_msg_t *flux_event_encodef (const char *topic, const char *fmt, ...);
flux_msg_t *flux_event_pack (const char *topic, const char *fmt, ...);

#endif /* !FLUX_CORE_EVENT_H */

Expand Down
2 changes: 1 addition & 1 deletion src/common/libflux/heartbeat.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ flux_msg_t *flux_heartbeat_encode (int epoch)
{
flux_msg_t *msg = NULL;

if (!(msg = flux_event_encodef ("hb", "{ s:i }", "epoch", epoch)))
if (!(msg = flux_event_pack ("hb", "{ s:i }", "epoch", epoch)))
return NULL;
return msg;
}
Expand Down
4 changes: 2 additions & 2 deletions src/common/libflux/test/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ int main (int argc, char *argv[])
flux_msg_destroy (msg);

/* formatted payload */
ok ((msg = flux_event_encodef ("foo.bar", "{s:i}", "foo", 42)) != NULL,
"flux_event_encodef packed payload object");
ok ((msg = flux_event_pack ("foo.bar", "{s:i}", "foo", 42)) != NULL,
"flux_event_pack packed payload object");
i = 0;
ok (flux_event_unpack (msg, &topic, "{s:i}", "foo", &i) == 0,
"flux_event_unpack unpacked payload object");
Expand Down
4 changes: 2 additions & 2 deletions src/common/libjsc/jstatctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,8 @@ static int send_state_event (flux_t *h, job_state_t st, int64_t j)
jsc_job_num2state (st));
goto done;
}
if ((msg = flux_event_encodef (topic, "{ s:I }", "lwj", j)) == NULL) {
flux_log_error (h, "flux_event_encodef");
if ((msg = flux_event_pack (topic, "{ s:I }", "lwj", j)) == NULL) {
flux_log_error (h, "flux_event_pack");
goto done;
}
if (flux_send (h, msg, 0) < 0)
Expand Down
6 changes: 3 additions & 3 deletions src/modules/barrier/barrier.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,9 @@ static int exit_event_send (flux_t *h, const char *name, int errnum)
flux_msg_t *msg = NULL;
int rc = -1;

if (!(msg = flux_event_encodef ("barrier.exit", "{s:s s:i}",
"name", name,
"errnum", errnum)))
if (!(msg = flux_event_pack ("barrier.exit", "{s:s s:i}",
"name", name,
"errnum", errnum)))
goto done;
if (flux_send (h, msg, 0) < 0)
goto done;
Expand Down
4 changes: 2 additions & 2 deletions src/modules/wreck/job.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ static void send_create_event (flux_t *h, int64_t id,
const char *path, char *topic)
{
flux_msg_t *msg;
msg = flux_event_encodef (topic, "{s:I,s:s}",
"lwj", id, "kvs_path", path);
msg = flux_event_pack (topic, "{s:I,s:s}",
"lwj", id, "kvs_path", path);
if (msg == NULL) {
flux_log_error (h, "failed to create state change event");
return;
Expand Down
8 changes: 4 additions & 4 deletions src/modules/wreck/wrexecd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1158,10 +1158,10 @@ void send_job_state_event (struct prog_ctx *ctx, const char *state)
goto out;
}

if ((msg = flux_event_encodef (topic, "{ s:I, s:s }",
"lwj", ctx->id,
"kvs_path", ctx->kvspath)) == NULL) {
wlog_err (ctx, "flux_event_encodef: %s", flux_strerror (errno));
if ((msg = flux_event_pack (topic, "{ s:I, s:s }",
"lwj", ctx->id,
"kvs_path", ctx->kvspath)) == NULL) {
wlog_err (ctx, "flux_event_pack: %s", flux_strerror (errno));
goto out;
}

Expand Down

0 comments on commit 5cea390

Please sign in to comment.