From: Michael Vrable Date: Fri, 6 Aug 2010 21:08:59 +0000 (-0700) Subject: Add a null storage implementation. X-Git-Url: http://git.vrable.net/?a=commitdiff_plain;h=4e24d47abcb5b0e97ab13afc8f97f8fdcab14843;p=bluesky.git Add a null storage implementation. 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. --- diff --git a/bluesky/store.c b/bluesky/store.c index 23e7047..5cc475e 100644 --- a/bluesky/store.c +++ b/bluesky/store.c @@ -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"); }