Skip to content

Commit 10360b1

Browse files
chu11mergify[bot]
authored andcommitted
job-list: add internal func to get job attrs
Problem: In the future, other functions within job-list will need a list of the job attrs that can be retrieved for each job. Solution: Create a new private helper function job_attrs(), which will return a list of valid job attrs.
1 parent 9f3b418 commit 10360b1

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

src/modules/job-list/job-list.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@
2020
#include "list.h"
2121
#include "idsync.h"
2222

23+
static const char *attrs[] = {
24+
"userid", "urgency", "priority", "t_submit",
25+
"t_depend", "t_run", "t_cleanup", "t_inactive",
26+
"state", "name", "ntasks", "nnodes",
27+
"ranks", "nodelist", "success", "exception_occurred",
28+
"exception_type", "exception_severity",
29+
"exception_note", "result", "expiration",
30+
"annotations", "waitstatus", "dependencies",
31+
NULL
32+
};
33+
34+
const char **job_attrs (void)
35+
{
36+
return attrs;
37+
}
38+
2339
static void stats_cb (flux_t *h, flux_msg_handler_t *mh,
2440
const flux_msg_t *msg, void *arg)
2541
{

src/modules/job-list/job-list.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ struct list_ctx {
2525
zhashx_t *idsync_waits;
2626
};
2727

28+
const char **job_attrs (void);
29+
2830
#endif /* _FLUX_JOB_LIST_H */
2931

3032
/*

src/modules/job-list/list.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#endif
1616
#include <jansson.h>
1717
#include <flux/core.h>
18+
#include <assert.h>
1819

1920
#include "src/common/libutil/errno_safe.h"
2021
#include "src/common/libczmqcontainers/czmq_containers.h"
@@ -556,14 +557,7 @@ int list_attrs_append (json_t *a, const char *attr)
556557
void list_attrs_cb (flux_t *h, flux_msg_handler_t *mh,
557558
const flux_msg_t *msg, void *arg)
558559
{
559-
const char *attrs[] = { "userid", "urgency", "priority", "t_submit",
560-
"t_depend", "t_run", "t_cleanup", "t_inactive",
561-
"state", "name", "ntasks", "nnodes",
562-
"ranks", "nodelist", "success", "exception_occurred",
563-
"exception_type", "exception_severity",
564-
"exception_note", "result", "expiration",
565-
"annotations", "waitstatus", "dependencies",
566-
NULL };
560+
const char **attrs;
567561
json_t *a;
568562
int i;
569563

@@ -572,6 +566,9 @@ void list_attrs_cb (flux_t *h, flux_msg_handler_t *mh,
572566
goto error;
573567
}
574568

569+
attrs = job_attrs ();
570+
assert (attrs);
571+
575572
for (i = 0; attrs[i] != NULL; i++) {
576573
if (list_attrs_append (a, attrs[i]) < 0)
577574
goto error;

0 commit comments

Comments
 (0)