Line data Source code
1 : /*
2 : * If not stated otherwise in this file or this component's LICENSE file the
3 : * following copyright and licenses apply:
4 : *
5 : * Copyright 2023 Sky UK
6 : *
7 : * Licensed under the Apache License, Version 2.0 (the "License");
8 : * you may not use this file except in compliance with the License.
9 : * You may obtain a copy of the License at
10 : *
11 : * http://www.apache.org/licenses/LICENSE-2.0
12 : *
13 : * Unless required by applicable law or agreed to in writing, software
14 : * distributed under the License is distributed on an "AS IS" BASIS,
15 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 : * See the License for the specific language governing permissions and
17 : * limitations under the License.
18 : */
19 :
20 : #ifndef RIALTO_SERVERMANAGER_SERVICE_CONFIG_HELPER_H_
21 : #define RIALTO_SERVERMANAGER_SERVICE_CONFIG_HELPER_H_
22 :
23 : #include "IConfigReaderFactory.h"
24 : #include "LoggingLevels.h"
25 : #include "SessionServerCommon.h"
26 : #include <chrono>
27 : #include <list>
28 : #include <map>
29 : #include <memory>
30 : #include <string>
31 :
32 : namespace rialto::servermanager::service
33 : {
34 : class ConfigHelper
35 : {
36 : public:
37 : ConfigHelper(std::unique_ptr<IConfigReaderFactory> &&configReaderFactory,
38 : const firebolt::rialto::common::ServerManagerConfig &config);
39 13 : ~ConfigHelper() = default;
40 :
41 : std::list<std::string> getSessionServerEnvVars() const;
42 : const std::string &getSessionServerPath() const;
43 : std::chrono::milliseconds getSessionServerStartupTimeout() const;
44 : std::chrono::seconds getHealthcheckInterval() const;
45 : firebolt::rialto::common::SocketPermissions getSocketPermissions() const;
46 : unsigned int getNumOfPreloadedServers() const;
47 : unsigned int getNumOfFailedPingsBeforeRecovery() const;
48 : const rialto::servermanager::service::LoggingLevels &getLoggingLevels() const;
49 :
50 : #ifdef RIALTO_ENABLE_CONFIG_FILE
51 : private:
52 : void readConfigFile(const std::string &filePath);
53 : void mergeEnvVariables();
54 : #endif // RIALTO_ENABLE_CONFIG_FILE
55 :
56 : private:
57 : std::unique_ptr<IConfigReaderFactory> m_configReaderFactory;
58 : std::map<std::string, std::string> m_sessionServerEnvVars;
59 : std::map<std::string, std::string> m_envVarsFromConfigFile;
60 : std::map<std::string, std::string> m_extraEnvVarsFromConfigFile;
61 : std::string m_sessionServerPath;
62 : std::chrono::milliseconds m_sessionServerStartupTimeout;
63 : std::chrono::seconds m_healthcheckInterval;
64 : firebolt::rialto::common::SocketPermissions m_socketPermissions;
65 : unsigned int m_numOfPreloadedServers;
66 : unsigned int m_numOfFailedPingsBeforeRecovery;
67 : rialto::servermanager::service::LoggingLevels m_loggingLevels;
68 : };
69 : } // namespace rialto::servermanager::service
70 :
71 : #endif // RIALTO_SERVERMANAGER_SERVICE_CONFIG_HELPER_H_
|