Separate store configs from the implems

Rework the `Store` hierarchy so that there's now one hierarchy for the
store configs and one for the implementations (where each implementation
extends the corresponding config). So a class hierarchy like

```
StoreConfig-------->Store
    |                 |
    v                 v
SubStoreConfig----->SubStore
    |                 |
    v                 v
SubSubStoreConfig-->SubSubStore
```

(with virtual inheritance to prevent DDD).

The advantage of this architecture is that we can now introspect the configuration of a store without having to instantiate the store itself
This commit is contained in:
regnat
2020-09-16 13:53:08 +02:00
parent aa4eac3788
commit 22afa8fb4d
13 changed files with 120 additions and 83 deletions
+8 -8
View File
@@ -7,7 +7,12 @@ namespace nix {
MakeError(UploadToHTTP, Error);
class HttpBinaryCacheStore : public BinaryCacheStore
struct HttpBinaryCacheStoreConfig : virtual BinaryCacheStoreConfig
{
using BinaryCacheStoreConfig::BinaryCacheStoreConfig;
};
class HttpBinaryCacheStore : public BinaryCacheStore, public HttpBinaryCacheStoreConfig
{
private:
@@ -23,16 +28,11 @@ private:
public:
HttpBinaryCacheStore(
const Params & params)
: HttpBinaryCacheStore("dummy", params)
{
}
HttpBinaryCacheStore(
const Path & _cacheUri,
const Params & params)
: BinaryCacheStore(params)
, HttpBinaryCacheStoreConfig(params)
, cacheUri(_cacheUri)
{
if (cacheUri.back() == '/')
@@ -176,6 +176,6 @@ protected:
};
static RegisterStoreImplementation<HttpBinaryCacheStore> regStore;
static RegisterStoreImplementation<HttpBinaryCacheStore, HttpBinaryCacheStoreConfig> regStore;
}