1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-02 21:51:50 +02:00

Create CommonSSHStoreConfig::createSSHMaster

By moving `host` to the config, we can do a lot further cleanups and
dedups. This anticipates a world where we always go `StoreReference` ->
`*StoreConfig` -> `Store*` rather than skipping the middle step too.

Progress on #10766

Progress on https://github.com/NixOS/hydra/issues/1164
This commit is contained in:
John Ericson 2024-05-23 12:14:53 -04:00
parent 17964441d9
commit 3e9c3738d3
7 changed files with 61 additions and 58 deletions

View file

@ -32,34 +32,21 @@ struct SSHStoreConfig : virtual RemoteStoreConfig, virtual CommonSSHStoreConfig
class SSHStore : public virtual SSHStoreConfig, public virtual RemoteStore
{
SSHStore(
std::string_view scheme,
std::string host,
const Params & params)
: StoreConfig(params)
, RemoteStoreConfig(params)
, CommonSSHStoreConfig(params)
, SSHStoreConfig(params)
, Store(params)
, RemoteStore(params)
, host(host)
, master(
host,
sshKey.get(),
sshPublicHostKey.get(),
// Use SSH master only if using more than 1 connection.
connections->capacity() > 1,
compress)
{
}
public:
SSHStore(
std::string_view scheme,
std::string_view host,
const Params & params)
: SSHStore{scheme, SSHStoreConfig::extractConnStr(scheme, host), params}
: StoreConfig(params)
, RemoteStoreConfig(params)
, CommonSSHStoreConfig(scheme, host, params)
, SSHStoreConfig(params)
, Store(params)
, RemoteStore(params)
, master(createSSHMaster(
// Use SSH master only if using more than 1 connection.
connections->capacity() > 1))
{
}
@ -119,6 +106,15 @@ struct MountedSSHStoreConfig : virtual SSHStoreConfig, virtual LocalFSStoreConfi
{
}
MountedSSHStoreConfig(std::string_view scheme, std::string_view host, StringMap params)
: StoreConfig(params)
, RemoteStoreConfig(params)
, CommonSSHStoreConfig(scheme, host, params)
, SSHStoreConfig(params)
, LocalFSStoreConfig(params)
{
}
const std::string name() override { return "Experimental SSH Store with filesystem mounted"; }
std::string doc() override
@ -158,7 +154,7 @@ public:
const Params & params)
: StoreConfig(params)
, RemoteStoreConfig(params)
, CommonSSHStoreConfig(params)
, CommonSSHStoreConfig(scheme, host, params)
, SSHStoreConfig(params)
, LocalFSStoreConfig(params)
, MountedSSHStoreConfig(params)