// Daemon
collecty_daemon* daemon;
- // Methods
- const collecty_module_methods* methods;
+ // Implementation
+ const collecty_module_impl* impl;
// Event Loop
sd_event* loop;
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));
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
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));
}
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)
}
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;
// 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);
}
const char* collecty_module_name(collecty_module* self) {
- return self->methods->name;
+ return self->impl->name;
}
#define collecty_module_path(module, object, path) \
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)
}
// 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;
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;
const char* rows;
} collecty_rrd_rra;
-typedef struct collecty_module_methods {
+typedef struct collecty_module_impl {
const char* name;
// RRD Schema
// 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);