-
Notifications
You must be signed in to change notification settings - Fork 27
cpp impl: Split Up Files #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ba7763c
cpp impl: add namespace score::mw::pers::kvs
joshualicht 9f66f5a
cpp impl: rename MyErrorCode to ErrorCode
joshualicht 90404ab
cpp impl: Split Code-Files
joshualicht 7ebcd32
cpp impl: Update BUILD Files
joshualicht 9cf30fd
cpp tests: Split Files
joshualicht 1698199
cpp tests: add benchmark to workflow
joshualicht d685f30
cpp impl: Change namespace definition
joshualicht 6b87607
cpp tests: Update Workflow Name
joshualicht c476af4
cpp impl: update example usage
joshualicht c89b918
cpp impl: rename namespace to score::mw::per:kvs
joshualicht File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # ******************************************************************************* | ||
| # Copyright (c) 2025 Contributors to the Eclipse Foundation | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
|
|
||
| cc_library( | ||
| name = "error", | ||
| srcs = [ | ||
| "error.cpp", | ||
| ], | ||
| hdrs = [ | ||
| "error.hpp", | ||
| ], | ||
| visibility = [ | ||
| "//src/cpp/src:__pkg__", | ||
| "//src/cpp/tests:__pkg__", | ||
| ], | ||
| deps = [ | ||
| "@score-baselibs//score/result:result", | ||
| ], | ||
| ) | ||
|
|
||
| cc_library( | ||
| name = "kvs_helper", | ||
| srcs = [ | ||
| "kvs_helper.cpp", | ||
| ], | ||
| hdrs = [ | ||
| "kvs_helper.hpp", | ||
| ], | ||
| visibility = [ | ||
| "//src/cpp/src:__pkg__", | ||
| "//src/cpp/tests:__pkg__", | ||
| ], | ||
| deps = [ | ||
| ":error", | ||
| "//src/cpp/src:kvsvalue", | ||
| "@score-baselibs//score/json", | ||
| ], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| /******************************************************************************** | ||
| * Copyright (c) 2025 Contributors to the Eclipse Foundation | ||
| * | ||
| * See the NOTICE file(s) distributed with this work for additional | ||
| * information regarding copyright ownership. | ||
| * | ||
| * This program and the accompanying materials are made available under the | ||
| * terms of the Apache License Version 2.0 which is available at | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| ********************************************************************************/ | ||
| #include "error.hpp" | ||
|
|
||
| namespace score::mw::per::kvs { | ||
|
|
||
| /*********************** Error Implementation *********************/ | ||
| std::string_view MyErrorDomain::MessageFor(score::result::ErrorCode const& code) const noexcept | ||
| { | ||
| std::string_view msg; | ||
| switch (static_cast<ErrorCode>(code)) | ||
| { | ||
| case ErrorCode::UnmappedError: | ||
| msg = "Error that was not yet mapped"; | ||
| break; | ||
| case ErrorCode::FileNotFound: | ||
| msg = "File not found"; | ||
| break; | ||
| case ErrorCode::KvsFileReadError: | ||
| msg = "KVS file read error"; | ||
| break; | ||
| case ErrorCode::KvsHashFileReadError: | ||
| msg = "KVS hash file read error"; | ||
| break; | ||
| case ErrorCode::JsonParserError: | ||
| msg = "JSON parser error"; | ||
| break; | ||
| case ErrorCode::JsonGeneratorError: | ||
| msg = "JSON generator error"; | ||
| break; | ||
| case ErrorCode::PhysicalStorageFailure: | ||
| msg = "Physical storage failure"; | ||
| break; | ||
| case ErrorCode::IntegrityCorrupted: | ||
| msg = "Integrity corrupted"; | ||
| break; | ||
| case ErrorCode::ValidationFailed: | ||
| msg = "Validation failed"; | ||
| break; | ||
| case ErrorCode::EncryptionFailed: | ||
| msg = "Encryption failed"; | ||
| break; | ||
| case ErrorCode::ResourceBusy: | ||
| msg = "Resource is busy"; | ||
| break; | ||
| case ErrorCode::OutOfStorageSpace: | ||
| msg = "Out of storage space"; | ||
| break; | ||
| case ErrorCode::QuotaExceeded: | ||
| msg = "Quota exceeded"; | ||
| break; | ||
| case ErrorCode::AuthenticationFailed: | ||
| msg = "Authentication failed"; | ||
| break; | ||
| case ErrorCode::KeyNotFound: | ||
| msg = "Key not found"; | ||
| break; | ||
| case ErrorCode::KeyDefaultNotFound: | ||
| msg = "Key default value not found"; | ||
| break; | ||
| case ErrorCode::SerializationFailed: | ||
| msg = "Serialization failed"; | ||
| break; | ||
| case ErrorCode::InvalidSnapshotId: | ||
| msg = "Invalid snapshot ID"; | ||
| break; | ||
| case ErrorCode::ConversionFailed: | ||
| msg = "Conversion failed"; | ||
| break; | ||
| case ErrorCode::MutexLockFailed: | ||
| msg = "Mutex failed"; | ||
| break; | ||
| case ErrorCode::InvalidValueType: | ||
| msg = "Invalid value type"; | ||
| break; | ||
| default: | ||
| msg = "Unknown Error!"; | ||
| break; | ||
| } | ||
|
|
||
| return msg; | ||
| } | ||
|
|
||
| score::result::Error MakeError(ErrorCode code, std::string_view user_message) noexcept | ||
| { | ||
| return {static_cast<score::result::ErrorCode>(code), my_error_domain, user_message}; | ||
| } | ||
|
|
||
| } /* namespace score::mw::per::kvs */ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| /******************************************************************************** | ||
| * Copyright (c) 2025 Contributors to the Eclipse Foundation | ||
| * | ||
| * See the NOTICE file(s) distributed with this work for additional | ||
| * information regarding copyright ownership. | ||
| * | ||
| * This program and the accompanying materials are made available under the | ||
| * terms of the Apache License Version 2.0 which is available at | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| ********************************************************************************/ | ||
| #ifndef SCORE_LIB_KVS_INTERNAL_ERROR_HPP | ||
| #define SCORE_LIB_KVS_INTERNAL_ERROR_HPP | ||
|
|
||
| #include "score/result/result.h" | ||
|
|
||
| namespace score::mw::per::kvs { | ||
|
|
||
| /* @brief */ | ||
| enum class ErrorCode : score::result::ErrorCode { | ||
| /* Error that was not yet mapped*/ | ||
| UnmappedError, | ||
|
|
||
| /* File not found*/ | ||
| FileNotFound, | ||
|
|
||
| /* KVS file read error*/ | ||
| KvsFileReadError, | ||
|
|
||
| /* KVS hash file read error*/ | ||
| KvsHashFileReadError, | ||
|
|
||
| /* JSON parser error*/ | ||
| JsonParserError, | ||
|
|
||
| /* JSON generator error*/ | ||
| JsonGeneratorError, | ||
|
|
||
| /* Physical storage failure*/ | ||
| PhysicalStorageFailure, | ||
|
|
||
| /* Integrity corrupted*/ | ||
| IntegrityCorrupted, | ||
|
|
||
| /* Validation failed*/ | ||
| ValidationFailed, | ||
|
|
||
| /* Encryption failed*/ | ||
| EncryptionFailed, | ||
|
|
||
| /* Resource is busy*/ | ||
| ResourceBusy, | ||
|
|
||
| /* Out of storage space*/ | ||
| OutOfStorageSpace, | ||
|
|
||
| /* Quota exceeded*/ | ||
| QuotaExceeded, | ||
|
|
||
| /* Authentication failed*/ | ||
| AuthenticationFailed, | ||
|
|
||
| /* Key not found*/ | ||
| KeyNotFound, | ||
|
|
||
| /* Key default value not found*/ | ||
| KeyDefaultNotFound, | ||
|
|
||
| /* Serialization failed*/ | ||
| SerializationFailed, | ||
|
|
||
| /* Invalid snapshot ID*/ | ||
| InvalidSnapshotId, | ||
|
|
||
| /* Conversion failed*/ | ||
| ConversionFailed, | ||
|
|
||
| /* Mutex failed*/ | ||
| MutexLockFailed, | ||
|
|
||
| /* Invalid value type*/ | ||
| InvalidValueType, | ||
| }; | ||
|
|
||
| class MyErrorDomain final : public score::result::ErrorDomain | ||
| { | ||
| public: | ||
| std::string_view MessageFor(score::result::ErrorCode const& code) const noexcept override; | ||
| }; | ||
|
|
||
| constexpr MyErrorDomain my_error_domain; | ||
| score::result::Error MakeError(ErrorCode code, std::string_view user_message = "") noexcept; | ||
|
|
||
| } /* namespace score::mw::per::kvs */ | ||
|
|
||
| #endif /* SCORE_LIB_KVS_INTERNAL_ERROR_HPP */ |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the split of this internal folder for?
example like in comm - namespace score::mw::com::impl - https://github.com/eclipse-score/communication/blob/main/score/mw/com/impl/com_error.h
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to replicate the folder structures of the baselibs components. E.g. JSON Component: Here we also have error files in an internal folder, but they still are exposed due to bazel deps.
I dont use an internal namespace for error, because if an application wants to use the kvs errorcode (e.g. while checking for an specific errorcode after a failed operation), you would always need to write an internal namespace for this, what is (at least in my understanding) not quite ideal. Json for example also doesnt have an impl namespace for errorcodes error.h json)
For "real" internal-only operations (like kvs_helper) we can align on the usage of an internal namespace, but since this change only affects the kvs itself and is no interface change, i personally would do this in a different PR and get this merged beforehand.
Also in the last FT Meeting we talked about the structure of internal files, because error is only semi internal since it is (as you said) exposed. So the question was, if the error files should be in the internal folder or directly in the src folder. We aligned, that this question should be taken in Architecture Community and we proceed like the way its currently done in Baselibs (and in this PR).
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO
,Error should not be in internal folder . For others if you have a internal folder then it should mean that these are internal and not for public user right.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we also thought this. But then on the other hand in more or less every baselibs component error is part of the internal folder. Thats why we moved this question to Architecture Community and change it in persistency afterwards if needed.