diff --git a/src/core/store.c b/src/core/store.c
index 22e965ff1858c9891cbf862e3f1af7e91d50a6c8..7671e9800f13a0ac0a81e2b24817d95b0f0a83ef 100644 (file)
--- a/src/core/store.c
+++ b/src/core/store.c
store_attribute, store_service_attr, store_metric_attr,
};
+/*
+ * TODO: let prepare and execute accept a store object as their user_data
+ * object
+ */
+
+static sdb_object_t *
+prepare_query(sdb_ast_node_t *ast,
+ sdb_strbuf_t __attribute__((unused)) *errbuf,
+ sdb_object_t __attribute__((unused)) *user_data)
+{
+ return SDB_OBJ(sdb_store_query_prepare(ast));
+} /* prepare_query */
+
+static int
+execute_query(sdb_object_t *q,
+ sdb_strbuf_t *buf, sdb_strbuf_t *errbuf,
+ sdb_object_t __attribute__((unused)) *user_data)
+{
+ return sdb_store_query_execute(QUERY(q), buf, errbuf);
+} /* execute_query */
+
+static sdb_store_reader_t store_reader = {
+ prepare_query, execute_query,
+};
+
/*
* public API
*/
sdb_log(SDB_LOG_ERR, "store: Failed to allocate store");
return -1;
}
- return sdb_plugin_register_writer("memstore",
- &store_writer, SDB_OBJ(global_store));
+ if (sdb_plugin_register_writer("memstore",
+ &store_writer, SDB_OBJ(global_store)))
+ return -1;
+ return sdb_plugin_register_reader("memstore",
+ &store_reader, SDB_OBJ(global_store));
} /* sdb_store_init */
void
sdb_avltree_clear(global_store->hosts);
} /* sdb_store_clear */
-bool
-sdb_store_has_host(const char *name)
-{
- sdb_host_t *host;
-
- if ((! global_store) || (! name))
- return false;
-
- host = lookup_host(global_store, name, /* canonicalize = */ 0);
- sdb_object_deref(SDB_OBJ(host));
- return host != NULL;
-} /* sdb_store_has_host */
-
sdb_store_obj_t *
sdb_store_get_host(const char *name)
{
return 0;
} /* sdb_store_get_attr */
+/* TODO: sdb_store_fetch_timeseries should move into the plugin module */
+
int
sdb_store_fetch_timeseries(const char *hostname, const char *metric,
sdb_timeseries_opts_t *opts, sdb_strbuf_t *buf)