]> git.ipfire.org Git - collecty.git/commitdiff
graph: Add a render function to jump into the individual graphs
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 2 Oct 2025 08:57:35 +0000 (08:57 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 2 Oct 2025 08:57:35 +0000 (08:57 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/graph.c
src/daemon/graph.h

index 39d8069236fb77c7381ac699ea2c68679f79e7d3..e043418d4500931d006f1d56d82d76795a4ca638 100644 (file)
@@ -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);
index da4856cf598a4b1733baa52fb1114e3f3460f34e..332234447e08d9d6201b32646b3fe171956a3d3d 100644 (file)
 
 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,