-
Notifications
You must be signed in to change notification settings - Fork 24
feat: add DataProvider and OperationProvider plugin interfaces #355
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
Open
bburda
wants to merge
11
commits into
main
Choose a base branch
from
feature/plugin-entity-framework
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d5ba505
add DataProvider and OperationProvider interfaces
bburda 1dcd49f
discover DataProvider and OperationProvider via dlsym
bburda 42a6198
add per-entity plugin ownership tracking to PluginManager
bburda 2b35719
enable IntrospectionProvider in all discovery modes
bburda 9fb1d71
add plugin routing fields to EntityInfo
bburda 1898a38
delegate data requests to DataProvider for plugin entities
bburda 5788289
delegate operation requests to OperationProvider for plugin entities
bburda 167a4d6
auto-deduce data/operations capabilities from plugin providers
bburda 81db09c
add tests for plugin entity ownership routing
bburda ffd1d2e
fix: include data/operation providers in GatewayPluginLoadResult move…
bburda a30ec6d
add FaultProvider interface for plugin fault/DTC resources
bburda 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
84 changes: 84 additions & 0 deletions
84
src/ros2_medkit_gateway/include/ros2_medkit_gateway/providers/data_provider.hpp
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,84 @@ | ||
| // Copyright 2026 bburda | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <nlohmann/json.hpp> | ||
| #include <string> | ||
| #include <tl/expected.hpp> | ||
|
|
||
| namespace ros2_medkit_gateway { | ||
|
|
||
| enum class DataProviderError { | ||
| EntityNotFound, | ||
| ResourceNotFound, | ||
| ReadOnly, | ||
| WriteOnly, | ||
| TransportError, | ||
| Timeout, | ||
| InvalidValue, | ||
| Internal | ||
| }; | ||
|
|
||
| struct DataProviderErrorInfo { | ||
| DataProviderError code; | ||
| std::string message; | ||
| int http_status{500}; ///< Suggested HTTP status code | ||
| }; | ||
|
|
||
| /** | ||
| * @brief Provider interface for entity data resources | ||
| * | ||
| * Typed provider interface for plugins that serve SOVD data resources | ||
| * (GET /{entity_type}/{id}/data, GET /{entity_type}/{id}/data/{name}). | ||
| * Unlike LogProvider/ScriptProvider (singletons), multiple DataProvider | ||
| * plugins can coexist - each handles its own set of entities. | ||
| * | ||
| * Entity ownership is determined by IntrospectionProvider: entities | ||
| * created by a plugin's introspect() are routed to that plugin's | ||
| * DataProvider. | ||
| * | ||
| * @par Thread safety | ||
| * All methods may be called from multiple HTTP handler threads concurrently. | ||
| * Implementations must provide their own synchronization. | ||
| * | ||
| * @see GatewayPlugin for the base class all plugins must also implement | ||
| * @see OperationProvider for the operations counterpart | ||
| */ | ||
| class DataProvider { | ||
| public: | ||
| virtual ~DataProvider() = default; | ||
|
|
||
| /// List available data resources for an entity | ||
| /// @param entity_id SOVD entity ID (e.g., "openbsw_demo_ecu") | ||
| /// @return JSON with {"items": [...]} array of data resource descriptors | ||
| virtual tl::expected<nlohmann::json, DataProviderErrorInfo> list_data(const std::string & entity_id) = 0; | ||
|
|
||
| /// Read a specific data resource | ||
| /// @param entity_id SOVD entity ID | ||
| /// @param resource_name Data resource name (e.g., "hardcoded_data") | ||
| /// @return JSON response body for the data resource | ||
| virtual tl::expected<nlohmann::json, DataProviderErrorInfo> read_data(const std::string & entity_id, | ||
| const std::string & resource_name) = 0; | ||
|
|
||
| /// Write a data resource value | ||
| /// @param entity_id SOVD entity ID | ||
| /// @param resource_name Data resource name | ||
| /// @param value JSON value to write | ||
| /// @return JSON response body confirming the write | ||
| virtual tl::expected<nlohmann::json, DataProviderErrorInfo> | ||
| write_data(const std::string & entity_id, const std::string & resource_name, const nlohmann::json & value) = 0; | ||
| }; | ||
|
|
||
| } // namespace ros2_medkit_gateway | ||
71 changes: 71 additions & 0 deletions
71
src/ros2_medkit_gateway/include/ros2_medkit_gateway/providers/fault_provider.hpp
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,71 @@ | ||
| // Copyright 2026 bburda | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <nlohmann/json.hpp> | ||
| #include <string> | ||
| #include <tl/expected.hpp> | ||
|
|
||
| namespace ros2_medkit_gateway { | ||
|
|
||
| enum class FaultProviderError { EntityNotFound, FaultNotFound, TransportError, Timeout, Internal }; | ||
|
|
||
| struct FaultProviderErrorInfo { | ||
| FaultProviderError code; | ||
| std::string message; | ||
| int http_status{500}; ///< Suggested HTTP status code | ||
| }; | ||
|
|
||
| /** | ||
| * @brief Provider interface for entity fault/DTC resources | ||
| * | ||
| * Typed provider interface for plugins that serve SOVD faults | ||
| * (GET /{entity_type}/{id}/faults, GET /{entity_type}/{id}/faults/{code}). | ||
| * Per-entity routing like DataProvider. | ||
| * | ||
| * Plugins implementing this interface query their backend (e.g., UDS | ||
| * ReadDTCInformation 0x19) on demand and return faults in SOVD format. | ||
| * | ||
| * @par Thread safety | ||
| * All methods may be called concurrently. Implementations must synchronize. | ||
| * | ||
| * @see GatewayPlugin for the base class all plugins must also implement | ||
| * @see DataProvider for the data counterpart | ||
| */ | ||
| class FaultProvider { | ||
| public: | ||
| virtual ~FaultProvider() = default; | ||
|
|
||
| /// List faults for an entity | ||
| /// @param entity_id SOVD entity ID | ||
| /// @return JSON with {"items": [...]} array of fault descriptors | ||
| virtual tl::expected<nlohmann::json, FaultProviderErrorInfo> list_faults(const std::string & entity_id) = 0; | ||
|
|
||
| /// Get a specific fault with environment data | ||
| /// @param entity_id SOVD entity ID | ||
| /// @param fault_code Fault code (e.g., DTC identifier) | ||
| /// @return JSON response with fault detail + environment data | ||
| virtual tl::expected<nlohmann::json, FaultProviderErrorInfo> get_fault(const std::string & entity_id, | ||
| const std::string & fault_code) = 0; | ||
|
|
||
| /// Clear a fault | ||
| /// @param entity_id SOVD entity ID | ||
| /// @param fault_code Fault code to clear | ||
| /// @return JSON response confirming the clear | ||
| virtual tl::expected<nlohmann::json, FaultProviderErrorInfo> clear_fault(const std::string & entity_id, | ||
| const std::string & fault_code) = 0; | ||
| }; | ||
|
|
||
| } // namespace ros2_medkit_gateway |
71 changes: 71 additions & 0 deletions
71
src/ros2_medkit_gateway/include/ros2_medkit_gateway/providers/operation_provider.hpp
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,71 @@ | ||
| // Copyright 2026 bburda | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <nlohmann/json.hpp> | ||
| #include <string> | ||
| #include <tl/expected.hpp> | ||
|
|
||
| namespace ros2_medkit_gateway { | ||
|
|
||
| enum class OperationProviderError { | ||
| EntityNotFound, | ||
| OperationNotFound, | ||
| InvalidParameters, | ||
| TransportError, | ||
| Timeout, | ||
| Rejected, | ||
| Internal | ||
| }; | ||
|
|
||
| struct OperationProviderErrorInfo { | ||
| OperationProviderError code; | ||
| std::string message; | ||
| int http_status{500}; ///< Suggested HTTP status code | ||
| }; | ||
|
|
||
| /** | ||
| * @brief Provider interface for entity operations | ||
| * | ||
| * Typed provider interface for plugins that serve SOVD operations | ||
| * (GET /{entity_type}/{id}/operations, POST /{entity_type}/{id}/operations/{name}). | ||
| * Per-entity routing like DataProvider. | ||
| * | ||
| * @par Thread safety | ||
| * All methods may be called concurrently. Implementations must synchronize. | ||
| * | ||
| * @see GatewayPlugin for the base class all plugins must also implement | ||
| * @see DataProvider for the data counterpart | ||
| */ | ||
| class OperationProvider { | ||
| public: | ||
| virtual ~OperationProvider() = default; | ||
|
|
||
| /// List available operations for an entity | ||
| /// @param entity_id SOVD entity ID | ||
| /// @return JSON with {"items": [...]} array of operation descriptors | ||
| virtual tl::expected<nlohmann::json, OperationProviderErrorInfo> list_operations(const std::string & entity_id) = 0; | ||
|
|
||
| /// Execute an operation | ||
| /// @param entity_id SOVD entity ID | ||
| /// @param operation_name Operation name (e.g., "session_control") | ||
| /// @param parameters JSON parameters from request body | ||
| /// @return JSON response body with operation result | ||
| virtual tl::expected<nlohmann::json, OperationProviderErrorInfo> | ||
| execute_operation(const std::string & entity_id, const std::string & operation_name, | ||
| const nlohmann::json & parameters) = 0; | ||
| }; | ||
|
|
||
| } // namespace ros2_medkit_gateway |
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
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.
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.
These new provider interfaces are part of the public plugin API (including the required dlsym export names in plugin_loader). The PR currently doesn’t update any developer-facing docs describing how to implement/export DataProvider/OperationProvider (and expected JSON schemas / error mapping). Please add documentation in the appropriate docs section (e.g., docs/design or a plugin author guide) and reference it here.