Skip to content
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

[CURA-11035] Plugins specify a verion-range, slots just a version. #1952

Merged
merged 3 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions include/plugins/exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
}

Expand Down
4 changes: 2 additions & 2 deletions include/plugins/metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
};

Expand Down
8 changes: 4 additions & 4 deletions include/plugins/pluginproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ 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
* ResponseTp - gRPC convertible response type, or dummy -- if stub is a proper invoke-stub, this is enforced by the specialization of the invoke component
*
* Class provides methods for validating the plugin, making requests and processing responses.
*/
template<plugins::v0::SlotID SlotID, utils::CharRangeLiteral SlotVersionRng, class Stub, class ValidatorTp, typename RequestTp, typename ResponseTp>
template<plugins::v0::SlotID SlotID, utils::CharRangeLiteral SlotVersion, class Stub, class ValidatorTp, typename RequestTp, typename ResponseTp>
class PluginProxy
{
// type aliases for easy use
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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_metadata> plugin_info_{ std::optional<plugin_metadata>(std::nullopt) }; ///< Optional object that holds the plugin metadata, set after handshake
};
Expand Down
14 changes: 7 additions & 7 deletions include/plugins/slotproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<plugins::v0::SlotID SlotID, utils::CharRangeLiteral SlotVersionRng, class Stub, class ValidatorTp, class RequestTp, class ResponseTp, class Default>
template<plugins::v0::SlotID SlotID, utils::CharRangeLiteral SlotVersion, class Stub, class ValidatorTp, class RequestTp, class ResponseTp, class Default>
class SlotProxy
{
Default default_process{};
using value_type = PluginProxy<SlotID, SlotVersionRng, Stub, ValidatorTp, RequestTp, ResponseTp>;
using value_type = PluginProxy<SlotID, SlotVersion, Stub, ValidatorTp, RequestTp, ResponseTp>;
std::optional<value_type> plugin_{ std::nullopt };

public:
Expand Down
10 changes: 5 additions & 5 deletions include/plugins/slots.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ struct infill_generate_default
*/
template<class Default = default_process>
using slot_simplify_
= SlotProxy<v0::SlotID::SIMPLIFY_MODIFY, "<=1.0.0", slots::simplify::v0::modify::SimplifyModifyService::Stub, Validator, simplify_request, simplify_response, Default>;
= SlotProxy<v0::SlotID::SIMPLIFY_MODIFY, "0.1.0-alpha", slots::simplify::v0::modify::SimplifyModifyService::Stub, Validator, simplify_request, simplify_response, Default>;

template<class Default = default_process>
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,
Expand All @@ -91,7 +91,7 @@ using slot_infill_generate_ = SlotProxy<
template<class Default = default_process>
using slot_postprocess_ = SlotProxy<
v0::SlotID::POSTPROCESS_MODIFY,
"<=1.0.0",
"0.1.0-alpha",
slots::postprocess::v0::modify::PostprocessModifyService::Stub,
Validator,
postprocess_request,
Expand All @@ -100,12 +100,12 @@ using slot_postprocess_ = SlotProxy<

template<class Default = default_process>
using slot_settings_broadcast_
= SlotProxy<v0::SlotID::SETTINGS_BROADCAST, "<=1.0.0", slots::broadcast::v0::BroadcastService::Stub, Validator, broadcast_settings_request, empty, Default>;
= SlotProxy<v0::SlotID::SETTINGS_BROADCAST, "0.1.0-alpha", slots::broadcast::v0::BroadcastService::Stub, Validator, broadcast_settings_request, empty, Default>;

template<class Default = default_process>
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,
Expand Down
4 changes: 2 additions & 2 deletions include/plugins/validator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
};

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/converters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ 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;
}

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 },
Expand Down
Loading