summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c67634d)
raw | patch | inline | side by side (parent: c67634d)
author | Sebastian Harl <sh@tokkee.org> | |
Sat, 16 Aug 2014 16:14:06 +0000 (18:14 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sat, 16 Aug 2014 16:14:06 +0000 (18:14 +0200) |
This function fetches a time-series from a named backend data-store using a
previously registered "time-series fetcher" callback.
previously registered "time-series fetcher" callback.
src/core/plugin.c | patch | blob | history | |
src/include/core/plugin.h | patch | blob | history |
diff --git a/src/core/plugin.c b/src/core/plugin.c
index 85dd76f410dbccfdb27f6bbf9fff3c0ee4653f27..d4bf1bd78b3dee2c1eb5e5c610e5a5bc5620dd84 100644 (file)
--- a/src/core/plugin.c
+++ b/src/core/plugin.c
return ret;
} /* sdb_plugin_logf */
+sdb_timeseries_t *
+sdb_plugin_fetch_timeseries(const char *type, const char *id,
+ sdb_timeseries_opts_t *opts)
+{
+ sdb_plugin_cb_t *plugin;
+ sdb_plugin_fetch_ts_cb callback;
+ sdb_timeseries_t *ts;
+
+ ctx_t *old_ctx;
+
+ if ((! type) || (! id) || (! opts))
+ return NULL;
+
+ plugin = SDB_PLUGIN_CB(sdb_llist_search_by_name(ts_fetcher_list, type));
+ if (! plugin) {
+ sdb_log(SDB_LOG_ERR, "core: Cannot fetch time-series of type %s: "
+ "no such plugin loaded");
+ errno = ENOENT;
+ return NULL;
+ }
+
+ old_ctx = ctx_set(plugin->cb_ctx);
+ callback = (sdb_plugin_fetch_ts_cb)plugin->cb_callback;
+ ts = callback(id, opts, plugin->cb_user_data);
+ ctx_set(old_ctx);
+ return ts;
+} /* sdb_plugin_fetch_timeseries */
+
/* vim: set tw=78 sw=4 ts=4 noexpandtab : */
index 4ccc983c446551db07ec729b4c7b26cfc8161b8b..0dce87705fb5cb5793c2b7500fd774dae18ec910 100644 (file)
int
sdb_plugin_logf(int prio, const char *fmt, ...);
+/*
+ * sdb_plugin_fetch_timeseries:
+ * Fetch 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. The time-series option specify which data
+ * to fetch.
+ *
+ * Returns:
+ * - a time-series on success
+ * - NULL else
+ */
+sdb_timeseries_t *
+sdb_plugin_fetch_timeseries(const char *type, const char *id,
+ sdb_timeseries_opts_t *opts);
+
#ifdef __cplusplus
} /* extern "C" */
#endif