return r;
}
+static int td_source_check(td_source* self) {
+ // Check if name is set
+ if (!self->impl->name) {
+ ERROR(self->ctx, "Source has no name\n");
+ return -EINVAL;
+ }
+
+ // Check if either init or heartbeat exists
+ if (!self->impl->init && !self->impl->heartbeat) {
+ ERROR(self->ctx, "Source %s has neither an init, nor a heartbeat function\n",
+ td_source_name(self));
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
static void td_source_free(td_source* self) {
if (self->impl->free)
self->impl->free(self->ctx);
// Store the implementation
self->impl = impl;
+ // Check if the implementation is complete
+ r = td_source_check(self);
+ if (r < 0)
+ goto ERROR;
+
// Register heartbeat
r = td_source_register_heartbeat(self);
if (r < 0)