Adding a new ready condition FileState - #402
Conversation
License Check Results🚀 The license check job ran with the Bazel command: bazel run --lockfile_mode=error //:license-checkStatus: Click to expand output |
|
The created documentation from the pull request is available at: docu-html |
FileState
6d1b659 to
90ddedb
Compare
053c31b to
9f99911
Compare
1ef9543 to
be8a923
Compare
be8a923 to
7cb0d43
Compare
3e74eea to
a4dacda
Compare
a4dacda to
4116757
Compare
4116757 to
7377dba
Compare
| table ReadyCondition { | ||
| process_state:ProcessState = null; // required | ||
| // Required state of the component's POSIX process. | ||
| process_state:ProcessState = null; // optional |
There was a problem hiding this comment.
| process_state:ProcessState = null; // optional | |
| process_state:ProcessState; // optional |
optional non-scalar values are currently all defined without "= null" in this schema because flatbuffer will just return nullptr if not configured which can be used for checking.
Its a bit counter intuitive, but the "= null" is used here for required scalar values so that it can be verified in the code that they have been configured (if they are just marked as required, then flatbuffer will return a default value and its not detectable if they have actually been configured or not).
| /// @brief Converts a FlatBuffer ReadyCondition to the config equivalent. | ||
| [[nodiscard]] score::cpp::expected<ReadyCondition, IConfigLoader::Error> convertReadyCondition( | ||
| const fb::ReadyCondition* fb_rc); | ||
| [[nodiscard]] std::optional<ReadyCondition> convertReadyCondition(const fb::ReadyCondition* fb_rc); |
There was a problem hiding this comment.
I assume convertReadyCondition should always return a ReturnCondition unless there is an error.
All the other functions use score::cpp::expected return value for this pattern. So I wonder if we shall stick to this pattern here
There was a problem hiding this comment.
Well we allow for not configuring a ReadyCondition and default to ProcessState::Running, currently this is defaulted in the ConfigAdapter. Should config handle default values? I think the <config type>loaders isn't a good place as this is specific to the fbs config.
- Fbs default - only applies to Fbs configs, if we change to others we would have to remember what is defaulted where.
- Python script - Not sure if adding more code here also makes sense, think we should reduce this file as much as possible.
- Code
- Config/FbsLoader - only applies to Fbs configs
- Config additional wrapper - would need to add wrapper.
- Component? Would allow for default values for a specific component type, might be useful.
I think we should define this somehow.
|
|
||
| const auto polling_interval_seconds = fb_fs->polling_interval(); | ||
| const auto polling_interval_ms = | ||
| std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::duration<double>(polling_interval_seconds)); |
There was a problem hiding this comment.
There is already secondsToMs helper method which has some additional safeguards e.g. to make sure that it does not round down to 0ms
| /// @brief Converts a FlatBuffer ProcessState enum to the config ProcessState. | ||
| [[nodiscard]] ProcessState convertProcessState(fb::ProcessState fb_state); | ||
| /// @brief Converts a FlatBuffer FileState struct to the config equivalent. | ||
| std::optional<FileState> convertFileState(const fb::FileState* fb_fs); |
There was a problem hiding this comment.
All the other methods use score::cpp::expected to return the converted value.
| adapter.deinitialize(); | ||
| } | ||
|
|
||
| TEST(ConfigurationAdapterDependencyTest, DependencyOnNonExistentComponentIsIgnored) |
There was a problem hiding this comment.
Name and description of the test suggest that the dependency is silently ignored, though this case actually crashes the process.
Using the assert is probably a good idea, as silently dropping the dependency would lead to the component being started under unexpected circumstances.
Adding a new ready condition for file state.
E.g. a component like "setup network" can wait for some
/dev/<network file>to make the component active. Then Later components can depend on this.