Add a null storage implementation.
authorMichael Vrable <mvrable@cs.ucsd.edu>
Fri, 6 Aug 2010 21:08:59 +0000 (14:08 -0700)
committerMichael Vrable <mvrable@cs.ucsd.edu>
Fri, 6 Aug 2010 21:08:59 +0000 (14:08 -0700)
This simply discards all data written to it.  Useful for testing purposes,
if all the data remains in the local log and so we never need to fetch data
from the storage implementation.

bluesky/store.c

index 23e7047..5cc475e 100644 (file)
@@ -501,6 +501,32 @@ static BlueSkyStoreImplementation filestore_impl = {
     .cleanup = filestore_cleanup,
 };
 
+/* A store implementation which simply discards all data, for testing. */
+static gpointer nullstore_create(const gchar *path)
+{
+    return (gpointer)nullstore_create;
+}
+
+static void nullstore_destroy(gpointer store)
+{
+}
+
+static void nullstore_submit(gpointer s, BlueSkyStoreAsync *async)
+{
+    bluesky_store_async_mark_complete(async);
+}
+
+static void nullstore_cleanup(gpointer store, BlueSkyStoreAsync *async)
+{
+}
+
+static BlueSkyStoreImplementation nullstore_impl = {
+    .create = nullstore_create,
+    .destroy = nullstore_destroy,
+    .submit = nullstore_submit,
+    .cleanup = nullstore_cleanup,
+};
+
 void bluesky_store_init()
 {
     store_implementations = g_hash_table_new(g_str_hash, g_str_equal);
@@ -508,4 +534,5 @@ void bluesky_store_init()
                                              bluesky_max_threads, FALSE, NULL);
     bluesky_store_register(&memstore_impl, "mem");
     bluesky_store_register(&filestore_impl, "file");
+    bluesky_store_register(&nullstore_impl, "null");
 }