From: Sebastian Harl Date: Sat, 10 Sep 2016 23:15:35 +0000 (-0400) Subject: plugin: Add a helper function to query timeseries information. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b2d31bc42a7694c671186081ee0cac077a188b99;p=sysdb.git plugin: Add a helper function to query timeseries information. This is a wrapper around the registered timeseries fetcher plugin. --- diff --git a/src/core/plugin.c b/src/core/plugin.c index 3fb0a77..ca04ae2 100644 --- a/src/core/plugin.c +++ b/src/core/plugin.c @@ -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) diff --git a/src/include/core/plugin.h b/src/include/core/plugin.h index b12af78..6574330 100644 --- a/src/include/core/plugin.h +++ b/src/include/core/plugin.h @@ -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