about summary refs log tree commit diff
path: root/src/libstore/store-api.hh
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-02-29T15·11+0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-02-29T15·11+0100
commit0b907321cca39368c5abcb3f5e6d73d5ab2e3e40 (patch)
tree96109f761cd46823a7c52d10dac6b907e4c7c70b /src/libstore/store-api.hh
parent012f8d187c1a4260ecd931ef69c7d4c83029d088 (diff)
Make store implementations pluggable
This for instance allows hydra-queue-runner to add the S3 backend
at runtime.
Diffstat (limited to 'src/libstore/store-api.hh')
-rw-r--r--src/libstore/store-api.hh17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh
index 488f32e16456..97e834ed2bd8 100644
--- a/src/libstore/store-api.hh
+++ b/src/libstore/store-api.hh
@@ -453,6 +453,23 @@ ref<Store> openStoreAt(const std::string & uri);
 ref<Store> openStore();
 
 
+/* Store implementation registration. */
+typedef std::function<std::shared_ptr<Store>(const std::string & uri)> OpenStore;
+
+struct RegisterStoreImplementation
+{
+    typedef std::vector<OpenStore> Implementations;
+    static Implementations * implementations;
+
+    RegisterStoreImplementation(OpenStore fun)
+    {
+        if (!implementations) implementations = new Implementations;
+        implementations->push_back(fun);
+    }
+};
+
+
+
 /* Display a set of paths in human-readable form (i.e., between quotes
    and separated by commas). */
 string showPaths(const PathSet & paths);