From b3fb6626654d2b384fd1b425a6d2cc5e7e348c56 Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Fri, 15 Sep 2023 12:06:19 +0200 Subject: [PATCH 1/2] Plugins specify a verion-range, slots just a version. Not the other way around as we have now. This also adheres closer to the way we handle front-end plugins. Ideally you'd maybe want both of them to be ranges, but that's for the future. part of CURA-11035 Co-authored-by: Jelle Spijker --- conanfile.py | 2 +- include/plugins/exception.h | 6 +++--- include/plugins/metadata.h | 4 ++-- include/plugins/pluginproxy.h | 8 ++++---- include/plugins/slotproxy.h | 14 +++++++------- include/plugins/slots.h | 10 +++++----- include/plugins/validator.h | 4 ++-- src/plugins/converters.cpp | 4 ++-- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/conanfile.py b/conanfile.py index 7d4d5dc601..69154f284d 100644 --- a/conanfile.py +++ b/conanfile.py @@ -85,7 +85,7 @@ def requirements(self): self.requires("arcus/5.3.0") self.requires("asio-grpc/2.6.0") self.requires("grpc/1.50.1") - self.requires("curaengine_grpc_definitions/(latest)@ultimaker/testing") + self.requires("curaengine_grpc_definitions/(latest)@ultimaker/cura_11035") # FIXME!: Put back to .../testing after merge! self.requires("clipper/6.4.2") self.requires("boost/1.82.0") self.requires("rapidjson/1.1.0") diff --git a/include/plugins/exception.h b/include/plugins/exception.h index a1816c7754..f593c2d69b 100644 --- a/include/plugins/exception.h +++ b/include/plugins/exception.h @@ -28,13 +28,13 @@ class ValidatorException : public std::exception ValidatorException(const auto& validator, const slot_metadata& slot_info, const plugin_metadata& plugin_info) noexcept : msg_(fmt::format( - "Failed to validate plugin '{}-{}' running at [{}] for slot '{}', slot range '{}' incompatible with plugin slot version '{}'", + "Failed to validate plugin '{}-{}' running at [{}] for slot '{}', version '{}' incompatible with plugin specified slot-version-range '{}'.", plugin_info.plugin_name, plugin_info.plugin_version, plugin_info.peer, slot_info.slot_id, - slot_info.version_range, - plugin_info.slot_version)) + slot_info.version, + plugin_info.slot_version_range)) { } diff --git a/include/plugins/metadata.h b/include/plugins/metadata.h index fadc807d77..af3e210342 100644 --- a/include/plugins/metadata.h +++ b/include/plugins/metadata.h @@ -18,7 +18,7 @@ namespace cura::plugins struct plugin_metadata { - std::string slot_version; + std::string slot_version_range; std::string plugin_name; std::string plugin_version; std::string peer; @@ -28,7 +28,7 @@ struct plugin_metadata struct slot_metadata { plugins::v0::SlotID slot_id; - std::string_view version_range; + std::string_view version; std::string_view engine_uuid; }; diff --git a/include/plugins/pluginproxy.h b/include/plugins/pluginproxy.h index 102e76833f..2ff7b5c0c3 100644 --- a/include/plugins/pluginproxy.h +++ b/include/plugins/pluginproxy.h @@ -50,7 +50,7 @@ namespace cura::plugins * * Template arguments are: * SlotID - plugin slot ID - * SlotVersionRng - plugin version range + * SlotVersion - slot version used -- will be the only version available in the engine for that slot, since there is just the latest version of the slot a.t.m. * Stub - process stub type * ValidatorTp - validator type * RequestTp - gRPC convertible request type, or dummy -- if stub is a proper invoke-stub, this is enforced by the specialization of the invoke component @@ -58,7 +58,7 @@ namespace cura::plugins * * Class provides methods for validating the plugin, making requests and processing responses. */ -template +template class PluginProxy { // type aliases for easy use @@ -131,7 +131,7 @@ class PluginProxy spdlog::error(status.error_message()); throw exceptions::RemoteException(slot_info_, status.error_message()); } - if (! plugin_info.plugin_name.empty() && ! plugin_info.slot_version.empty()) + if (! plugin_info.plugin_name.empty() && ! plugin_info.slot_version_range.empty()) { plugin_info_.emplace(plugin_info); } @@ -340,7 +340,7 @@ class PluginProxy req_converter_type req_{}; ///< The Invoke request converter object. rsp_converter_type rsp_{}; ///< The Invoke response converter object. slot_metadata slot_info_{ .slot_id = SlotID, - .version_range = SlotVersionRng.value, + .version = SlotVersion.value, .engine_uuid = Application::getInstance().instance_uuid }; ///< Holds information about the plugin slot. std::optional plugin_info_{ std::optional(std::nullopt) }; ///< Optional object that holds the plugin metadata, set after handshake }; diff --git a/include/plugins/slotproxy.h b/include/plugins/slotproxy.h index 84ba7846c3..037db10a19 100644 --- a/include/plugins/slotproxy.h +++ b/include/plugins/slotproxy.h @@ -28,19 +28,19 @@ namespace cura::plugins * for communication with plugins assigned to the slot. It delegates plugin requests to the * corresponding PluginProxy object and provides a default behavior when no plugin is available. * - * @tparam Slot The plugin slot ID. - * @tparam Validator The type used for validating the plugin. + * @tparam SlotID The plugin slot ID. + * @tparam SlotVersion The version of the indicated slot. * @tparam Stub The process stub type. - * @tparam Prepare The prepare type. - * @tparam Request The gRPC convertible request type. - * @tparam Response The gRPC convertible response type. + * @tparam ValidatorTp The type used for validating the plugin. + * @tparam RequestTp The gRPC convertible request type. + * @tparam ResponseTp The gRPC convertible response type. * @tparam Default The default behavior when no plugin is available. */ -template +template class SlotProxy { Default default_process{}; - using value_type = PluginProxy; + using value_type = PluginProxy; std::optional plugin_{ std::nullopt }; public: diff --git a/include/plugins/slots.h b/include/plugins/slots.h index 5b99ab52b0..ed7c91a4e6 100644 --- a/include/plugins/slots.h +++ b/include/plugins/slots.h @@ -69,12 +69,12 @@ struct infill_generate_default */ template using slot_simplify_ - = SlotProxy; + = SlotProxy; template using slot_infill_generate_ = SlotProxy< v0::SlotID::INFILL_GENERATE, - "<=1.0.0", + "0.1.0-alpha", slots::infill::v0::generate::InfillGenerateService::Stub, Validator, infill_generate_request, @@ -91,7 +91,7 @@ using slot_infill_generate_ = SlotProxy< template using slot_postprocess_ = SlotProxy< v0::SlotID::POSTPROCESS_MODIFY, - "<=1.0.0", + "0.1.0-alpha", slots::postprocess::v0::modify::PostprocessModifyService::Stub, Validator, postprocess_request, @@ -100,12 +100,12 @@ using slot_postprocess_ = SlotProxy< template using slot_settings_broadcast_ - = SlotProxy; + = SlotProxy; template using slot_gcode_paths_modify_ = SlotProxy< v0::SlotID::GCODE_PATHS_MODIFY, - "<=1.0.0", + "0.1.0-alpha", slots::gcode_paths::v0::modify::GCodePathsModifyService::Stub, Validator, gcode_paths_modify_request, diff --git a/include/plugins/validator.h b/include/plugins/validator.h index 0d18c074a3..ffe9cbba8e 100644 --- a/include/plugins/validator.h +++ b/include/plugins/validator.h @@ -33,8 +33,8 @@ class Validator */ Validator(const slot_metadata& slot_info, const plugin_metadata& plugin_info) { - auto slot_range = semver::range::detail::range(slot_info.version_range); - auto slot_version = semver::from_string(plugin_info.slot_version); + auto slot_range = semver::range::detail::range(plugin_info.slot_version_range); + auto slot_version = semver::from_string(slot_info.version); valid_ = slot_range.satisfies(slot_version, include_prerelease_); }; diff --git a/src/plugins/converters.cpp b/src/plugins/converters.cpp index 33e7d4882e..2ba03fe8c6 100644 --- a/src/plugins/converters.cpp +++ b/src/plugins/converters.cpp @@ -70,7 +70,7 @@ handshake_request::value_type handshake_request::operator()(const std::string& n { value_type message{}; message.set_slot_id(slot_info.slot_id); - message.set_version_range(slot_info.version_range.data()); + message.set_version(slot_info.version.data()); message.set_plugin_name(name); message.set_plugin_version(version); return message; @@ -78,7 +78,7 @@ handshake_request::value_type handshake_request::operator()(const std::string& n handshake_response::native_value_type handshake_response::operator()(const handshake_response::value_type& message, std::string_view peer) const { - return { .slot_version = message.slot_version(), + return { .slot_version_range = message.slot_version_range(), .plugin_name = message.plugin_name(), .plugin_version = message.plugin_version(), .peer = std::string{ peer }, From cf0c484079e10b5cbe3b6fe6531a365c3dbe2ed9 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Wed, 20 Sep 2023 07:34:45 +0200 Subject: [PATCH 2/2] Use latest grpc definitions CURA-11035 --- conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conanfile.py b/conanfile.py index 69154f284d..7d4d5dc601 100644 --- a/conanfile.py +++ b/conanfile.py @@ -85,7 +85,7 @@ def requirements(self): self.requires("arcus/5.3.0") self.requires("asio-grpc/2.6.0") self.requires("grpc/1.50.1") - self.requires("curaengine_grpc_definitions/(latest)@ultimaker/cura_11035") # FIXME!: Put back to .../testing after merge! + self.requires("curaengine_grpc_definitions/(latest)@ultimaker/testing") self.requires("clipper/6.4.2") self.requires("boost/1.82.0") self.requires("rapidjson/1.1.0")