diff options
| author | Stefan Boberg <[email protected]> | 2025-10-15 09:51:52 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2025-10-15 09:51:52 +0200 |
| commit | e747932819e2a64a1396cfbc3422a9b61c9470dc (patch) | |
| tree | 1db1d13cf7fe873d71128a7879d269174f8eaf16 /src/zenserver/storage/storageconfig.h | |
| parent | refactor builds cmd part3 (#573) (diff) | |
| download | zen-e747932819e2a64a1396cfbc3422a9b61c9470dc.tar.xz zen-e747932819e2a64a1396cfbc3422a9b61c9470dc.zip | |
restructured zenserver configuration (#575)
this breaks out the configuration logic to allow multiple applications to share common configuration and initialization logic whilst customizing chosen aspects of the process
Diffstat (limited to 'src/zenserver/storage/storageconfig.h')
| -rw-r--r-- | src/zenserver/storage/storageconfig.h | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/src/zenserver/storage/storageconfig.h b/src/zenserver/storage/storageconfig.h index ca0cf4135..acdaa099b 100644 --- a/src/zenserver/storage/storageconfig.h +++ b/src/zenserver/storage/storageconfig.h @@ -144,7 +144,7 @@ struct ZenWorkspacesConfig bool AllowConfigurationChanges = false; }; -struct ZenStorageServerOptions : public ZenServerOptions +struct ZenStorageServerConfig : public ZenServerConfig { ZenUpstreamCacheConfig UpstreamCacheConfig; ZenGcConfig GcConfig; @@ -155,19 +155,10 @@ struct ZenStorageServerOptions : public ZenServerOptions ZenBuildStoreConfig BuildStoreConfig; ZenWorkspacesConfig WorksSpacesConfig; std::filesystem::path PluginsConfigFile; // Path to plugins config file - std::filesystem::path BaseSnapshotDir; // Path to server state snapshot (will be copied into data dir on start) bool ObjectStoreEnabled = false; std::string ScrubOptions; }; -void ParseConfigFile(const std::filesystem::path& Path, - ZenStorageServerOptions& ServerOptions, - const cxxopts::ParseResult& CmdLineResult, - std::string_view OutputConfigFile); - -void ParsePluginsConfigFile(const std::filesystem::path& Path, ZenStorageServerOptions& ServerOptions, int BasePort); -void ValidateOptions(ZenStorageServerOptions& ServerOptions); - struct ZenStorageServerCmdLineOptions { // Note to those adding future options; std::filesystem::path-type options @@ -176,28 +167,49 @@ struct ZenStorageServerCmdLineOptions // expects paths in streams to be quoted but argv paths are unquoted. By // going into a std::string first, paths with whitespace parse correctly. std::string PluginsConfigFile; - std::string BaseSnapshotDir; - void AddCliOptions(cxxopts::Options& options, ZenStorageServerOptions& ServerOptions); - void ApplyOptions(cxxopts::Options& options, ZenStorageServerOptions& ServerOptions); + void AddCliOptions(cxxopts::Options& options, ZenStorageServerConfig& ServerOptions); + void ApplyOptions(cxxopts::Options& options, ZenStorageServerConfig& ServerOptions); std::string OpenIdProviderName; std::string OpenIdProviderUrl; std::string OpenIdClientId; - void AddSecurityOptions(cxxopts::Options& options, ZenStorageServerOptions& ServerOptions); + void AddSecurityOptions(cxxopts::Options& options, ZenStorageServerConfig& ServerOptions); std::string UpstreamCachePolicyOptions; - void AddCacheOptions(cxxopts::Options& options, ZenStorageServerOptions& ServerOptions); + void AddCacheOptions(cxxopts::Options& options, ZenStorageServerConfig& ServerOptions); - void AddGcOptions(cxxopts::Options& options, ZenStorageServerOptions& ServerOptions); + void AddGcOptions(cxxopts::Options& options, ZenStorageServerConfig& ServerOptions); std::vector<std::string> BucketConfigs; - void AddObjectStoreOptions(cxxopts::Options& options, ZenStorageServerOptions& ServerOptions); - void AddBuildStoreOptions(cxxopts::Options& options, ZenStorageServerOptions& ServerOptions); - void AddWorkspacesOptions(cxxopts::Options& options, ZenStorageServerOptions& ServerOptions); + void AddObjectStoreOptions(cxxopts::Options& options, ZenStorageServerConfig& ServerOptions); + void AddBuildStoreOptions(cxxopts::Options& options, ZenStorageServerConfig& ServerOptions); + void AddWorkspacesOptions(cxxopts::Options& options, ZenStorageServerConfig& ServerOptions); +}; + +struct ZenStorageServerConfigurator : public ZenServerConfiguratorBase +{ + ZenStorageServerConfigurator(ZenStorageServerConfig& ServerOptions) + : ZenServerConfiguratorBase(ServerOptions) + , m_ServerOptions(ServerOptions) + { + } + ~ZenStorageServerConfigurator() = default; + +private: + virtual void AddCliOptions(cxxopts::Options& options) override; + virtual void AddConfigOptions(LuaConfig::Options& Options) override; + virtual void ApplyOptions(cxxopts::Options& options) override; + virtual void OnConfigFileParsed(LuaConfig::Options& LuaOptions) override; + virtual void ValidateOptions() override; + + void ParsePluginsConfigFile(const std::filesystem::path& Path); + + ZenStorageServerConfig& m_ServerOptions; + ZenStorageServerCmdLineOptions m_StorageOptions; }; } // namespace zen |