diff options
author | Sara Golemon <sara.golemon@mongodb.com> | 2021-12-30 20:00:33 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-12-30 20:27:32 +0000 |
commit | 47d12041be895626acbdee7c6b5ae38594279d7d (patch) | |
tree | 9ff30d5ebb2eccb0ea03f5ec42f2ac84d7cecb18 /src/mongo/idl/server_parameter.h | |
parent | 69a2128b5e82896594aebc18643da2089e196220 (diff) | |
download | mongo-47d12041be895626acbdee7c6b5ae38594279d7d.tar.gz |
SERVER-59813 Simplify ServerParameter construction and add formal readonly parameters
Diffstat (limited to 'src/mongo/idl/server_parameter.h')
-rw-r--r-- | src/mongo/idl/server_parameter.h | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/mongo/idl/server_parameter.h b/src/mongo/idl/server_parameter.h index 276f542837a..8d8705071f6 100644 --- a/src/mongo/idl/server_parameter.h +++ b/src/mongo/idl/server_parameter.h @@ -56,6 +56,10 @@ namespace mongo { * At runtime, { setParameter : 1, ...} is used. */ enum class ServerParameterType { + /** + * May not be set at any time. + */ + kReadOnly, /** * Parameter can only be set via runCommand. @@ -82,11 +86,6 @@ public: using Map = std::map<std::string, ServerParameter*>; ServerParameter(StringData name, ServerParameterType spt); - ServerParameter(ServerParameterSet* sps, - StringData name, - bool allowedToChangeAtStartup, - bool allowedToChangeAtRuntime); - ServerParameter(ServerParameterSet* sps, StringData name); virtual ~ServerParameter() = default; std::string name() const { @@ -97,16 +96,21 @@ public: * @return if you can set on command line or config file */ bool allowedToChangeAtStartup() const { - return _allowedToChangeAtStartup; + return (_type == ServerParameterType::kStartupOnly) || + (_type == ServerParameterType::kStartupAndRuntime); } /** * @param if you can use (get|set)Parameter */ bool allowedToChangeAtRuntime() const { - return _allowedToChangeAtRuntime; + return (_type == ServerParameterType::kRuntimeOnly) || + (_type == ServerParameterType::kStartupAndRuntime); } + ServerParameterType getServerParameterType() const { + return _type; + } virtual void append(OperationContext* opCtx, BSONObjBuilder& b, const std::string& name) = 0; @@ -132,10 +136,13 @@ protected: // Helper for translating setParameter values from BSON to string. StatusWith<std::string> coerceToString(const BSONElement&, bool redact); + // Used by DisabledTestParameter to avoid re-registering the server parameter. + struct NoRegistrationTag {}; + ServerParameter(StringData name, ServerParameterType spt, NoRegistrationTag); + private: std::string _name; - bool _allowedToChangeAtStartup; - bool _allowedToChangeAtRuntime; + ServerParameterType _type; bool _testOnly = false; }; |