Repository navigation
implement configuration by file. - #595
Ahmed-Elsaka-JC wants to merge 2 commits into
Conversation
License Check Results🚀 The license check job ran with the Bazel command: bazel run --lockfile_mode=error //:license-checkStatus: Click to expand output |
|
Documentation preview for this pull request is available at: |
a358d13 to
417bc2b
Compare
417bc2b to
308a7d9
Compare
arkjedrz
left a comment
There was a problem hiding this comment.
Review to internal/ files is not thorough yet, since many raised points relate to design.
| #include <optional> | ||
|
|
||
| /* | ||
| * This header declares the abstraction over deployment-time "configuration by file" discovery and |
There was a problem hiding this comment.
Since this is generated - ask Your LLM of choice to rework docs and comments. Following rules seem to be a good first step.
- Be concise, use short sentences.
- One sentence per line.
- If a sentence is too long, try to rephrase it first.
- This one's interesting, but turned out to be the most effective. Write as if it was written for an impatient developer that is not using English as a native language.
This is required, because otherwise those docs needlessly meander.
| namespace score::mw::per::kvs | ||
| { | ||
|
|
||
| class IKvsConfigParser |
There was a problem hiding this comment.
Please use non-prefixed name for interface, and then suffix Impl for concrete implementation.
This is the already-required approach in baselibs, already followed by logging.
| #include <cstddef> | ||
| #include <optional> | ||
|
|
||
| /* |
There was a problem hiding this comment.
Follow new docs format. /// for docs, Doxygen-style @xyz keywords, // for comments.
| * input: the `InstanceId::id` of the KVS instance about to be opened. | ||
| * behavior: Discovers whether a configuration-by-file document applies at all, and if so | ||
| * parses and strictly validates it in full before looking for an entry matching | ||
| * `instance_id`. Performs no mutation; intended to be called once per |
There was a problem hiding this comment.
Performs no mutation -> then the function should be marked as const, and docs require no additional statement.
| * input: the `InstanceId::id` of the KVS instance about to be opened. | ||
| * behavior: Discovers whether a configuration-by-file document applies at all, and if so | ||
| * parses and strictly validates it in full before looking for an entry matching | ||
| * `instance_id`. Performs no mutation; intended to be called once per |
There was a problem hiding this comment.
intended to be called once per -> additional request to LLM, do not state what is the expected usage and even where it is used, this is just a fluff.
| (void)value; | ||
| const std::string_view key_view = key.GetAsStringView(); | ||
| bool found = false; | ||
| for (const auto& allowed_key : allowed) |
There was a problem hiding this comment.
std::any_of, return false quickly if not satisfied.
Do not use single point of return rule.
| score::Unexpected KvsConfigParser::fail(ErrorCode code, std::string_view user_message) const | ||
| { | ||
| const auto error = MakeError(code, user_message); | ||
| logger_->LogError() << "KVS config:" << error.Message() << error.UserMessage(); |
There was a problem hiding this comment.
logger_ can become an object placed in anonymous namespace, then this function can be in anonymous function as well. Or a KVS-wide internal object, because it's using the same code.
| return fail(ErrorCode::InvalidConfiguration, "unknown need_* value"); | ||
| } | ||
|
|
||
| /* |
There was a problem hiding this comment.
cpp is not a place for docs.
|
|
||
| /* | ||
| * Determine the directory containing the currently running binary. | ||
| * Used only as part of the fallback configuration file lookup; exposed for unit testing. |
There was a problem hiding this comment.
No fallback or candidates. It's a known path or an error.
EDIT: took a look at communication, here it's a default constructor or given path, but the overall approach is different - RuntimeConfiguration is created first, then provided to Initialize function. This is incompatible with persistency approach, but as mentioned in other comment - maybe other places in persistency component need a redesign too.
| * Determine the directory containing the currently running binary. | ||
| * Used only as part of the fallback configuration file lookup; exposed for unit testing. | ||
| */ | ||
| std::optional<std::string> running_binary_directory() const; |
There was a problem hiding this comment.
Do not pollute public API. I disagree this is needed, but if it is - move to anonymous namespace, and recreate in unit tests.
adding new support to config by file
#411