aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/http-binary-cache-store.cc
diff options
context:
space:
mode:
authorregnat <rg@regnat.ovh>2020-09-08 14:50:23 +0200
committerregnat <rg@regnat.ovh>2020-09-16 13:53:08 +0200
commit7d5bdf8b5679cc7b2b9b4d9caf5af9ca52211336 (patch)
tree42c5061563eaa66a36a30380ccbac721e8c7423e /src/libstore/http-binary-cache-store.cc
parent609a6d6d9f1a8689c2336301a2e4db01ad20037c (diff)
Make the store plugins more introspectable
Directly register the store classes rather than a function to build an instance of them. This gives the possibility to introspect static members of the class or choose different ways of instantiating them.
Diffstat (limited to 'src/libstore/http-binary-cache-store.cc')
-rw-r--r--src/libstore/http-binary-cache-store.cc24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/libstore/http-binary-cache-store.cc b/src/libstore/http-binary-cache-store.cc
index 1733239fb..6c3a16faf 100644
--- a/src/libstore/http-binary-cache-store.cc
+++ b/src/libstore/http-binary-cache-store.cc
@@ -24,7 +24,8 @@ private:
public:
HttpBinaryCacheStore(
- const Params & params, const Path & _cacheUri)
+ const Path & _cacheUri,
+ const Params & params)
: BinaryCacheStore(params)
, cacheUri(_cacheUri)
{
@@ -55,6 +56,13 @@ public:
}
}
+ static std::vector<std::string> uriPrefixes()
+ {
+ static bool forceHttp = getEnv("_NIX_FORCE_HTTP") == "1";
+ auto ret = std::vector<std::string>({"http", "https"});
+ if (forceHttp) ret.push_back("file");
+ return ret;
+ }
protected:
void maybeDisable()
@@ -162,18 +170,6 @@ protected:
};
-static RegisterStoreImplementation regStore([](
- const std::string & uri, const Store::Params & params)
- -> std::shared_ptr<Store>
-{
- static bool forceHttp = getEnv("_NIX_FORCE_HTTP") == "1";
- if (std::string(uri, 0, 7) != "http://" &&
- std::string(uri, 0, 8) != "https://" &&
- (!forceHttp || std::string(uri, 0, 7) != "file://"))
- return 0;
- auto store = std::make_shared<HttpBinaryCacheStore>(params, uri);
- store->init();
- return store;
-});
+[[maybe_unused]] static RegisterStoreImplementation<HttpBinaryCacheStore> regStore();
}