From d07e89b7d7a09c64d2f5fb89f152ffa74ae76e44 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 2 Oct 2025 08:57:35 +0000 Subject: [PATCH] graph: Add a render function to jump into the individual graphs Signed-off-by: Michael Tremer --- src/daemon/graph.c | 9 ++++++++- src/daemon/graph.h | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/daemon/graph.c b/src/daemon/graph.c index 39d8069..e043418 100644 --- a/src/daemon/graph.c +++ b/src/daemon/graph.c @@ -119,6 +119,10 @@ int collecty_graph_render(collecty_graph* self, // Log action DEBUG(self->ctx, "Rendering %s...\n", collecty_graph_get_name(self)); + // Fail if we don't have a render function + if (!self->impl->render) + return -ENOTSUP; + // Open a file handle to the output buffer f = open_memstream(buffer, length); if (!f) { @@ -132,7 +136,10 @@ int collecty_graph_render(collecty_graph* self, if (r < 0) goto ERROR; - // XXX TODO Fill this with content + // Call the implementation to add some arguments + r = self->impl->render(self->ctx, self, args); + if (r < 0) + goto ERROR; // Dump the command r = collecty_args_dump(args); diff --git a/src/daemon/graph.h b/src/daemon/graph.h index da4856c..3322344 100644 --- a/src/daemon/graph.h +++ b/src/daemon/graph.h @@ -23,14 +23,19 @@ typedef struct collecty_graph collecty_graph; +#include "args.h" #include "ctx.h" #include "daemon.h" +#include "graph.h" typedef struct collecty_graph_impl { const char* name; // Available int (*available)(collecty_ctx* ctx, collecty_daemon* daemon); + + // Render! + int (*render)(collecty_ctx* ctx, collecty_graph* graph, collecty_args* args); } collecty_graph_impl; int collecty_graph_create(collecty_graph** graph, -- 2.47.3