Code

plugin: Add a helper function to query timeseries information.
authorSebastian Harl <sh@tokkee.org>
Sat, 10 Sep 2016 23:15:35 +0000 (19:15 -0400)
committerSebastian Harl <sh@tokkee.org>
Sat, 10 Sep 2016 23:15:35 +0000 (19:15 -0400)
This is a wrapper around the registered timeseries fetcher plugin.

src/core/plugin.c
src/include/core/plugin.h

index 3fb0a77348bb098b414f9724fb9281598ae41463..ca04ae21efc8745efc62553cda354060ca54390d 100644 (file)
@@ -1555,6 +1555,31 @@ sdb_plugin_fetch_timeseries(const char *type, const char *id,
        return ts;
 } /* sdb_plugin_fetch_timeseries */
 
+sdb_timeseries_info_t *
+sdb_plugin_describe_timeseries(const char *type, const char *id)
+{
+       ts_fetcher_t *fetcher;
+       sdb_timeseries_info_t *ts_info;
+
+       ctx_t *old_ctx;
+
+       if ((! type) || (! id))
+               return NULL;
+
+       fetcher = TS_FETCHER(sdb_llist_search_by_name(timeseries_fetcher_list, type));
+       if (! fetcher) {
+               sdb_log(SDB_LOG_ERR, "core: Cannot describe time-series of type %s: "
+                               "no such plugin loaded", type);
+               errno = ENOENT;
+               return NULL;
+       }
+
+       old_ctx = ctx_set(fetcher->ts_ctx);
+       ts_info = fetcher->impl.describe(id, fetcher->ts_user_data);
+       ctx_set(old_ctx);
+       return ts_info;
+} /* sdb_plugin_describe_timeseries */
+
 int
 sdb_plugin_query(sdb_ast_node_t *ast,
                sdb_store_writer_t *w, sdb_object_t *wd, sdb_strbuf_t *errbuf)
index b12af783adc5f5cb4414496ef0d12704586684e2..6574330412417dee9de23b98715fc9ba4882eafe 100644 (file)
@@ -434,6 +434,20 @@ sdb_timeseries_t *
 sdb_plugin_fetch_timeseries(const char *type, const char *id,
                sdb_timeseries_opts_t *opts);
 
+/*
+ * sdb_plugin_describe_timeseries:
+ * Fetch information about the time-series identified by 'id' from a backend
+ * data-store of the specified 'type'. The type has to match an existing
+ * time-series fetcher callback's name. The identifier is passed through to
+ * the callback which then needs to make sense of it.
+ *
+ * Returns:
+ *  - a time-series information object on success
+ *  - NULL else
+ */
+sdb_timeseries_info_t *
+sdb_plugin_describe_timeseries(const char *type, const char *id);
+
 /*
  * sdb_plugin_query:
  * Query the store using the query specified by 'ast'. The result will be