Skip to content

Commit 880fc3b

Browse files
authored
config: move to rapidyaml and remove yaml-cpp 🚀 (#207)
Add rapidyaml 0.9.0 as a header-only dependency, and remove yaml-cpp. I refactored the code into a YamlReader and a YamlWriter, and tried to remove as much of rapidyaml from the parsing interface. The `schemaVersion` field in yaml files is deprecated in favor of `SchemaVersion` with capital s. The version so far was not validated when loading a config file. SILKIT-1739
1 parent 6a9ad3a commit 880fc3b

File tree

58 files changed

+47119
-3232
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+47119
-3232
lines changed

‎.gitmodules‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
[submodule "spdlog"]
22
path = ThirdParty/spdlog
33
url = https://github.com/gabime/spdlog
4-
[submodule "ThirdParty/yaml-cpp"]
5-
path = ThirdParty/yaml-cpp
6-
url = https://github.com/jbeder/yaml-cpp
74
[submodule "ThirdParty/asio"]
85
path = ThirdParty/asio
96
url = https://github.com/chriskohlhoff/asio.git

‎SilKit/source/CMakeLists.txt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ if ((CMAKE_CXX_COMPILER_ID STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
266266
set(SILKIT_LINK_EXCLUDE_LIBS "")
267267
# add the file name (xxx.a) to the list
268268
list(APPEND SILKIT_LINK_EXCLUDE_LIBS "$<TARGET_FILE_NAME:spdlog>")
269-
list(APPEND SILKIT_LINK_EXCLUDE_LIBS "$<TARGET_FILE_NAME:yaml-cpp>")
270269
# format the list such that the linker flag accepts it
271270
list(JOIN SILKIT_LINK_EXCLUDE_LIBS ":" SILKIT_LINK_EXCLUDE_LIBS)
272271
# add the excluded libs to the linker command line

‎SilKit/source/config/CMakeLists.txt‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ target_link_libraries(I_SilKit_Config
2929
INTERFACE
3030
${SILKIT_THIRD_PARTY_YAML_INTERFACE}
3131
I_SilKit_Util
32+
rapidyaml
3233
)
3334

3435
add_library(O_SilKit_Config OBJECT
@@ -40,12 +41,14 @@ add_library(O_SilKit_Config OBJECT
4041
ParticipantConfigurationFromXImpl.cpp
4142
Validation.hpp
4243
Validation.cpp
44+
4345
YamlParser.hpp
4446
YamlParser.cpp
45-
YamlConversion.hpp
46-
YamlConversion.cpp
47-
YamlSchema.hpp
48-
YamlSchema.cpp
47+
YamlReader.hpp
48+
YamlReader.cpp
49+
YamlWriter.hpp
50+
YamlWriter.cpp
51+
4952
YamlValidator.hpp
5053
YamlValidator.cpp
5154
)
@@ -55,8 +58,9 @@ target_link_libraries(O_SilKit_Config
5558

5659
PRIVATE SilKitInterface
5760
PRIVATE O_SilKit_Util_Filesystem
58-
PUBLIC yaml-cpp
5961
PRIVATE I_SilKit_Util_FileHelpers
62+
PUBLIC rapidyaml
63+
PRIVATE fmt::fmt
6064
)
6165

6266
target_include_directories(O_SilKit_Config
@@ -97,12 +101,12 @@ add_silkit_test_to_executable(SilKitUnitTests
97101

98102
add_silkit_test_to_executable(SilKitUnitTests
99103
SOURCES Test_YamlParser.cpp
100-
LIBS O_SilKit_Config yaml-cpp
104+
LIBS O_SilKit_Config rapidyaml
101105
)
102106

103107
add_silkit_test_to_executable(SilKitUnitTests
104108
SOURCES Test_YamlValidator.cpp
105-
LIBS O_SilKit_Config yaml-cpp
109+
LIBS O_SilKit_Config rapidyaml
106110
)
107111

108112
set(ParticipantTestCanConfigs

‎SilKit/source/config/Configuration.hpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
4040
namespace SilKit {
4141
namespace Config {
4242

43-
inline namespace v1 {
43+
inline namespace V1 {
4444

4545
// ================================================================================
4646
// Shared configuration declarations
@@ -322,7 +322,7 @@ inline Aggregation from_string(const std::string& aggregationStr)
322322
return Aggregation::Auto;
323323
}
324324

325-
} // namespace v1
325+
} // namespace V1
326326

327327
} // namespace Config
328328
} // namespace SilKit

‎SilKit/source/config/ParticipantConfiguration.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
2626

2727
namespace SilKit {
2828
namespace Config {
29-
inline namespace v1 {
29+
inline namespace V1 {
3030

3131
auto Label::ToPublicApi() const -> SilKit::Services::MatchingLabel
3232
{
@@ -81,12 +81,12 @@ auto Label::FromPublicApi(const SilKit::Services::MatchingLabel& label) -> Label
8181

8282
auto Label::VectorFromPublicApi(const std::vector<SilKit::Services::MatchingLabel>& labels) -> std::vector<Label>
8383
{
84-
std::vector<SilKit::Config::v1::Label> result;
84+
std::vector<SilKit::Config::V1::Label> result;
8585
std::transform(labels.begin(), labels.end(), std::back_inserter(result), Label::FromPublicApi);
8686
return result;
8787
}
8888

8989

90-
} // namespace v1
90+
} // namespace V1
9191
} // namespace Config
9292
} // namespace SilKit

‎SilKit/source/config/ParticipantConfiguration.hpp‎

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
4040

4141
namespace SilKit {
4242
namespace Config {
43-
inline namespace v1 {
43+
inline namespace V1 {
4444

4545
// ================================================================================
4646
// Internal controller service
@@ -337,6 +337,17 @@ struct Experimental
337337
Metrics metrics;
338338
};
339339

340+
// ================================================================================
341+
// Includes
342+
// ================================================================================
343+
344+
//! \brief Structure that contains experimental settings
345+
struct Includes
346+
{
347+
std::vector<std::string> searchPathHints;
348+
std::vector<std::string> files;
349+
};
350+
340351
// ================================================================================
341352
// Root
342353
// ================================================================================
@@ -349,8 +360,8 @@ struct ParticipantConfiguration : public IParticipantConfiguration
349360
//virtual auto ToYamlString() -> std::string override;
350361
//virtual auto ToJsonString() -> std::string override;
351362

352-
//! \brief Version of the JSON/YAML schema.
353-
std::string schemaVersion{"1"};
363+
//! \brief Version of the JSON/YAML schema. Currently is at 1
364+
std::string schemaVersion{""};
354365
//! \brief An optional user description for documentation purposes. Currently unused.
355366
std::string description;
356367
//! \brief An optional file path.
@@ -374,6 +385,7 @@ struct ParticipantConfiguration : public IParticipantConfiguration
374385
HealthCheck healthCheck;
375386
Tracing tracing;
376387
Extensions extensions;
388+
Includes includes;
377389
Middleware middleware;
378390
Experimental experimental;
379391
};
@@ -392,6 +404,7 @@ bool operator==(const MetricsSink& lhs, const MetricsSink& rhs);
392404
bool operator==(const Metrics& lhs, const Metrics& rhs);
393405
bool operator==(const Extensions& lhs, const Extensions& rhs);
394406
bool operator==(const Middleware& lhs, const Middleware& rhs);
407+
bool operator==(const Includes& lhs, const Includes& rhs);
395408
bool operator==(const ParticipantConfiguration& lhs, const ParticipantConfiguration& rhs);
396409
bool operator==(const TimeSynchronization& lhs, const TimeSynchronization& rhs);
397410
bool operator==(const Experimental& lhs, const Experimental& rhs);
@@ -403,6 +416,39 @@ auto operator<<(std::ostream& out, const Label& label) -> std::ostream&;
403416
bool operator<(const MetricsSink& lhs, const MetricsSink& rhs);
404417
bool operator>(const MetricsSink& lhs, const MetricsSink& rhs);
405418

406-
} // namespace v1
419+
} // namespace V1
407420
} // namespace Config
408421
} // namespace SilKit
422+
423+
namespace SilKitRegistry {
424+
namespace Config {
425+
namespace V1 {
426+
427+
constexpr inline auto GetSchemaVersion() -> const char*
428+
{
429+
return "1";
430+
}
431+
432+
struct Experimental
433+
{
434+
SilKit::Config::V1::Metrics metrics;
435+
};
436+
437+
struct RegistryConfiguration
438+
{
439+
std::string description{""};
440+
std::string schemaVersion{""};
441+
SilKit::Util::Optional<std::string> listenUri;
442+
SilKit::Util::Optional<bool> enableDomainSockets;
443+
SilKit::Util::Optional<std::string> dashboardUri;
444+
SilKit::Config::Logging logging{};
445+
Experimental experimental{};
446+
};
447+
448+
bool operator==(const Experimental& lhs, const Experimental& rhs);
449+
450+
451+
452+
} // namespace V1
453+
} // namespace Config
454+
} // namespace SilKitRegistry

0 commit comments

Comments
 (0)