From: Sebastian Harl Date: Tue, 6 Oct 2015 18:01:27 +0000 (+0200) Subject: store: Don't report an error if a missing writer callback isn't used. X-Git-Tag: sysdb-0.8.0~16 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3c1957886a4b8361f75d67a029ccc31069031af4;p=sysdb.git store: Don't report an error if a missing writer callback isn't used. That is, allow to emit store objects to an incomplete writer as long as all required callbacks are present. --- diff --git a/src/core/store_json.c b/src/core/store_json.c index 4fd309b..961e54c 100644 --- a/src/core/store_json.c +++ b/src/core/store_json.c @@ -384,9 +384,7 @@ sdb_store_json_formatter(sdb_strbuf_t *buf, int type, int flags) int sdb_store_emit(sdb_store_obj_t *obj, sdb_store_writer_t *w, sdb_object_t *wd) { - if ((! obj) || (! w) - || (! w->store_host) || (! w->store_service) - || (! w->store_metric) || (! w->store_attribute)) + if ((! obj) || (! w)) return -1; switch (obj->type) { @@ -399,6 +397,8 @@ sdb_store_emit(sdb_store_obj_t *obj, sdb_store_writer_t *w, sdb_object_t *wd) (const char * const *)obj->backends, obj->backends_num, }; + if (! w->store_host) + return -1; return w->store_host(&host, wd); } case SDB_SERVICE: @@ -411,6 +411,8 @@ sdb_store_emit(sdb_store_obj_t *obj, sdb_store_writer_t *w, sdb_object_t *wd) (const char * const *)obj->backends, obj->backends_num, }; + if (! w->store_service) + return -1; return w->store_service(&service, wd); } case SDB_METRIC: @@ -427,6 +429,8 @@ sdb_store_emit(sdb_store_obj_t *obj, sdb_store_writer_t *w, sdb_object_t *wd) (const char * const *)obj->backends, obj->backends_num, }; + if (! w->store_metric) + return -1; return w->store_metric(&metric, wd); } case SDB_ATTRIBUTE: @@ -445,6 +449,8 @@ sdb_store_emit(sdb_store_obj_t *obj, sdb_store_writer_t *w, sdb_object_t *wd) if (obj->parent && (obj->parent->type != SDB_HOST) && obj->parent->parent) attr.hostname = obj->parent->parent->_name; + if (! w->store_attribute) + return -1; return w->store_attribute(&attr, wd); } }