]> git.ipfire.org Git - collecty.git/commitdiff
modules: Rename methods to impl
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 3 Oct 2025 11:14:11 +0000 (11:14 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 3 Oct 2025 11:14:11 +0000 (11:14 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/module.c
src/daemon/module.h
src/daemon/modules.c
src/daemon/modules/conntrack.c
src/daemon/modules/conntrack.h
src/daemon/modules/contextswitches.c
src/daemon/modules/contextswitches.h
src/daemon/modules/loadavg.c
src/daemon/modules/loadavg.h

index fc21b83dd7204b32a52aa8dcc9b03d85fb8f6882..707ddc8de175d456c3a2c4f075efe02ffbaf7c63 100644 (file)
@@ -70,8 +70,8 @@ struct collecty_module {
        // Daemon
        collecty_daemon* daemon;
 
-       // Methods
-       const collecty_module_methods* methods;
+       // Implementation
+       const collecty_module_impl* impl;
 
        // Event Loop
        sd_event* loop;
@@ -89,7 +89,7 @@ static int collecty_module_heartbeat(sd_event_source* source, uint64_t usec, voi
        DEBUG(self->ctx, "Heartbeat called for %s\n", collecty_module_name(self));
 
        // Call the collect method
-       r = self->methods->collect(self->ctx, self);
+       r = self->impl->collect(self->ctx, self);
        if (r < 0) {
                ERROR(self->ctx, "collect() failed for %s: %s\n",
                        collecty_module_name(self), strerror(-r));
@@ -112,7 +112,7 @@ static int collecty_module_register_heartbeat(collecty_module* self) {
        int r;
 
        // No need to do this if we don't have a collect method
-       if (!self->methods->collect)
+       if (!self->impl->collect)
                return 0;
 
        // Call the heartbeat function immediately
@@ -130,11 +130,11 @@ static int collecty_module_init(collecty_module* self) {
        int r;
 
        // Do nothing if there is no init function
-       if (!self->methods->init)
+       if (!self->impl->init)
                return 0;
 
        // Initialize the module
-       r = self->methods->init(self->ctx);
+       r = self->impl->init(self->ctx);
        if (r < 0) {
                ERROR(self->ctx, "Failed to initialize %s: %s\n",
                        collecty_module_name(self), strerror(-r));
@@ -144,8 +144,8 @@ static int collecty_module_init(collecty_module* self) {
 }
 
 static void collecty_module_free(collecty_module* self) {
-       if (self->methods->free)
-               self->methods->free(self->ctx);
+       if (self->impl->free)
+               self->impl->free(self->ctx);
        if (self->events.heartbeat)
                sd_event_source_unref(self->events.heartbeat);
        if (self->loop)
@@ -158,7 +158,7 @@ static void collecty_module_free(collecty_module* self) {
 }
 
 int collecty_module_create(collecty_module** module,
-               collecty_ctx* ctx, collecty_daemon* daemon, const collecty_module_methods* methods) {
+               collecty_ctx* ctx, collecty_daemon* daemon, const collecty_module_impl* impl) {
        collecty_module* self = NULL;
        int r;
 
@@ -179,8 +179,8 @@ int collecty_module_create(collecty_module** module,
        // Fetch a reference to the event loop
        self->loop = collecty_daemon_loop(daemon);
 
-       // Store the methods
-       self->methods = methods;
+       // Store the implementation
+       self->impl = impl;
 
        // Register heartbeat
        r = collecty_module_register_heartbeat(self);
@@ -217,7 +217,7 @@ collecty_module* collecty_module_unref(collecty_module* self) {
 }
 
 const char* collecty_module_name(collecty_module* self) {
-       return self->methods->name;
+       return self->impl->name;
 }
 
 #define collecty_module_path(module, object, path) \
@@ -278,7 +278,7 @@ static int collecty_module_create_database(collecty_module* self, const char* pa
                goto ERROR;
 
        // Add all data sources
-       for (const collecty_rrd_ds* ds = self->methods->rrd_dss; ds->field; ds++) {
+       for (const collecty_rrd_ds* ds = self->impl->rrd_dss; ds->field; ds++) {
                // Format the minimum value
                r = collecty_format_number(min, ds->min);
                if (r < 0)
@@ -304,7 +304,7 @@ static int collecty_module_create_database(collecty_module* self, const char* pa
        }
 
        // Add all custom round-robin archives
-       for (const collecty_rrd_rra* rra = self->methods->rrd_rras; rra->type; rra++) {
+       for (const collecty_rrd_rra* rra = self->impl->rrd_rras; rra->type; rra++) {
                r = collecty_args_push(args, "RRA:%s:%.2f:%s:%s", rra->type, XFF, rra->steps, rra->rows);
                if (r < 0)
                        goto ERROR;
@@ -424,7 +424,7 @@ int collecty_module_render(collecty_module* self, collecty_args* args, const cha
                return r;
 
        // Add all data sources
-       for (const collecty_rrd_ds* ds = self->methods->rrd_dss; ds->field; ds++) {
+       for (const collecty_rrd_ds* ds = self->impl->rrd_dss; ds->field; ds++) {
                r = collecty_module_render_add_DEF(self, args, path, ds, object);
                if (r < 0)
                        return r;
index c4db55926c5eec3ee2d637c5163a8d5f55037f11..8be7c723b13189450cb10018e16a0168db9968e0 100644 (file)
@@ -53,7 +53,7 @@ typedef struct collecty_rrd_rra {
        const char* rows;
 } collecty_rrd_rra;
 
-typedef struct collecty_module_methods {
+typedef struct collecty_module_impl {
        const char* name;
 
        // RRD Schema
@@ -68,10 +68,10 @@ typedef struct collecty_module_methods {
 
        // Collect
        int (*collect)(collecty_ctx* ctx, collecty_module* module);
-} collecty_module_methods;
+} collecty_module_impl;
 
 int collecty_module_create(collecty_module** module,
-               collecty_ctx* ctx, collecty_daemon* daemon, const collecty_module_methods* methods);
+               collecty_ctx* ctx, collecty_daemon* daemon, const collecty_module_impl* impl);
 
 collecty_module* collecty_module_ref(collecty_module* self);
 collecty_module* collecty_module_unref(collecty_module* self);
index 24c5eeee21480990b3a0d33dcdd61b8ee753a147..6634cd0b1dfd8c5a3c23a3ede871c28773adefc5 100644 (file)
@@ -33,7 +33,7 @@
 #include "modules/loadavg.h"
 
 // Register all modules
-static const collecty_module_methods* module_impls[] = {
+static const collecty_module_impl* module_impls[] = {
        &conntrack_module,
        &contextswitches_module,
        &loadavg_module,
@@ -59,7 +59,7 @@ static int collecty_modules_init(collecty_modules* self) {
        int r;
 
        // Initialize all modules
-       for (const collecty_module_methods** impl = module_impls; *impl; impl++) {
+       for (const collecty_module_impl** impl = module_impls; *impl; impl++) {
                r = collecty_module_create(&module, self->ctx, self->daemon, *impl);
                if (r < 0)
                        return r;
index 0ecb5cd41efda83956de45194d20836497737004..dda367a63002015f5133054e43dc50c169fc4d0a 100644 (file)
@@ -50,7 +50,7 @@ static int conntrack_collect(collecty_ctx* ctx, collecty_module* module) {
        return collecty_module_submit(module, NULL, "%" PRIu64 ":%" PRIu64, count, max);
 }
 
-const collecty_module_methods conntrack_module = {
+const collecty_module_impl conntrack_module = {
        .name    = "conntrack",
 
        // RRD Data Sources
index 60bdc0781595569491086ba584d139e96742ae0c..68d555ee91bbd351e1edba565b91575669774815 100644 (file)
@@ -23,6 +23,6 @@
 
 #include "../module.h"
 
-extern const collecty_module_methods conntrack_module;
+extern const collecty_module_impl conntrack_module;
 
 #endif /* COLLECTY_MODULE_CONNTRACK_H */
index 4b1cc72297e8c842199f37d6dd5a6fff5796968b..bb3cf2a975c594254010b1e7454b2e08f64f4c57 100644 (file)
@@ -117,7 +117,7 @@ static int contextswitches_collect(collecty_ctx* ctx, collecty_module* module) {
        return collecty_module_submit(module, NULL, "%lld", total);
 }
 
-const collecty_module_methods contextswitches_module = {
+const collecty_module_impl contextswitches_module = {
        .name    = "contextswitches",
 
        // RRD Data Sources
index d363de6d25973429fded3a239ffc519fcc0dd746..9753c7adccf1bf8a84bf65e35df962d1e4991d1d 100644 (file)
@@ -23,6 +23,6 @@
 
 #include "../module.h"
 
-extern const collecty_module_methods contextswitches_module;
+extern const collecty_module_impl contextswitches_module;
 
 #endif /* COLLECTY_MODULE_CONTEXTSWITCHES_H */
index 15f9638f4a48f3ff30bd9739a4bb9a7adf1c2514..85794057b4a0a82ae9be12aba82f0def5f94faad 100644 (file)
@@ -38,7 +38,7 @@ static int loadavg_collect(collecty_ctx* ctx, collecty_module* module) {
                "%f:%f:%f", loadavg[0], loadavg[1], loadavg[2]);
 }
 
-const collecty_module_methods loadavg_module = {
+const collecty_module_impl loadavg_module = {
        .name    = "loadavg",
 
        // RRD Data Sources
index 679a978b7bfb455cf3e72650601defa033e84937..79083f7c567616fa1698ae1ee8c3bd766da13afe 100644 (file)
@@ -23,6 +23,6 @@
 
 #include "../module.h"
 
-extern const collecty_module_methods loadavg_module;
+extern const collecty_module_impl loadavg_module;
 
 #endif /* COLLECTY_MODULE_LOADAVG_H */