Re: [PR] MINIFICPP-2764 Controller Service CPP API [nifi-minifi-cpp]
martinzink merged PR #2152: URL: https://github.com/apache/nifi-minifi-cpp/pull/2152 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] MINIFICPP-2764 Controller Service CPP API [nifi-minifi-cpp]
martinzink commented on code in PR #2152:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2152#discussion_r3186712708
##
extension-framework/cpp-extension-lib/include/api/core/ControllerServiceImpl.h:
##
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+#include
+
+#include "ControllerServiceContext.h"
+#include "minifi-cpp/core/ControllerServiceMetadata.h"
+#include "minifi-cpp/utils/Id.h"
+#include "utils/SmallString.h"
+
+namespace org::apache::nifi::minifi::api {
+
+class Connection;
+
+namespace core {
+
+class ControllerServiceImpl {
Review Comment:
[add explanatory comments to
ControllerServiceImpl.h](https://github.com/apache/nifi-minifi-cpp/pull/2152/commits/a3960293ebcebfa01feb2aff7c2aed8f01349f87)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Re: [PR] MINIFICPP-2764 Controller Service CPP API [nifi-minifi-cpp]
szaszm commented on code in PR #2152:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2152#discussion_r3150005631
##
extension-framework/cpp-extension-lib/include/api/core/ControllerServiceImpl.h:
##
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+#include
+
+#include "ControllerServiceContext.h"
+#include "minifi-cpp/core/ControllerServiceMetadata.h"
+#include "minifi-cpp/utils/Id.h"
+#include "utils/SmallString.h"
+
+namespace org::apache::nifi::minifi::api {
+
+class Connection;
+
+namespace core {
+
+class ControllerServiceImpl {
Review Comment:
What is the purpose of this class? a description in a code comment would be
helpful IMO
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Re: [PR] MINIFICPP-2764 Controller Service CPP API [nifi-minifi-cpp]
martinzink commented on code in PR #2152:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2152#discussion_r3159365467
##
extension-framework/cpp-extension-lib/include/api/core/Resource.h:
##
@@ -145,4 +150,43 @@ void useProcessorClassDescription(Fn&& fn) {
fn(description);
}
+template
+void useControllerServiceClassDescription(Fn&& fn) {
+ std::vector> string_vector_cache;
+
+ const auto full_name = minifi::core::className();
+
+ std::vector class_properties =
utils::toProperties(Class::Properties, string_vector_cache);
+
+ MinifiControllerServiceClassDefinition description{.full_name =
utils::toStringView(full_name),
Review Comment:
agreed, i went with definition everywhere because the class already contains
description so it made more sense for me
[useProcessorClassDescription ->
useProcessorClassDefinition](https://github.com/apache/nifi-minifi-cpp/pull/2152/commits/97c898aac7001f4abd67a16b35f0f69f181c55be)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Re: [PR] MINIFICPP-2764 Controller Service CPP API [nifi-minifi-cpp]
martinzink commented on code in PR #2152:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2152#discussion_r3159360987
##
extension-framework/cpp-extension-lib/include/api/utils/ProcessorConfigUtils.h:
##
@@ -167,4 +167,28 @@ std::optional parseOptionalEnumProperty(const
core::ProcessContext& context,
return result.value();
}
+template
+ControllerServiceType* parseOptionalControllerService(const
core::ProcessContext& context, const minifi::core::PropertyReference& prop) {
+ const auto controller_service_name = context.getProperty(prop.name);
+ if (!controller_service_name || controller_service_name->empty()) {
+return nullptr;
+ }
+
+ nonstd::expected service =
context.getControllerService(*controller_service_name,
minifi::core::className());
Review Comment:
👍 [rebase
fix](https://github.com/apache/nifi-minifi-cpp/pull/2152/commits/991fa3e0ba38410828ca33d3de6ead23c91e39d4)
##
extension-framework/cpp-extension-lib/src/core/ProcessContext.cpp:
##
@@ -38,4 +38,17 @@ bool ProcessContext::hasNonEmptyProperty(std::string_view
name) const {
return MinifiProcessContextHasNonEmptyProperty(impl_,
utils::toStringView(name));
}
+nonstd::expected
ProcessContext::getControllerService(const std::string_view
controller_service_name,
+const std::string_view controller_service_class) const {
+ void* controller_service = nullptr;
Review Comment:
👍 [rebase
fix](https://github.com/apache/nifi-minifi-cpp/pull/2152/commits/991fa3e0ba38410828ca33d3de6ead23c91e39d4)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Re: [PR] MINIFICPP-2764 Controller Service CPP API [nifi-minifi-cpp]
martinzink commented on code in PR #2152:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2152#discussion_r3159167470
##
libminifi/test/libtest/unit/TestBase.cpp:
##
@@ -360,6 +360,27 @@ minifi::Connection*
TestPlan::addConnection(minifi::core::Processor* source_proc
return retVal;
}
+std::shared_ptr
TestPlan::addController(const std::string& name, const
std::shared_ptr& cs) {
Review Comment:
it will be used in #2153 and later on, we need this because we would like to
instantiate them with preexisting (instantiated through the API) controller
services
https://github.com/apache/nifi-minifi-cpp/pull/2153/changes#diff-d5f59e4f9d39633968dfdf29d96503d484179de5c8b66f72a0df9340745f3354R56-R62
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Re: [PR] MINIFICPP-2764 Controller Service CPP API [nifi-minifi-cpp]
fgerlits commented on code in PR #2152:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2152#discussion_r3155534324
##
extension-framework/cpp-extension-lib/include/api/utils/ProcessorConfigUtils.h:
##
@@ -167,4 +167,28 @@ std::optional parseOptionalEnumProperty(const
core::ProcessContext& context,
return result.value();
}
+template
+ControllerServiceType* parseOptionalControllerService(const
core::ProcessContext& context, const minifi::core::PropertyReference& prop) {
+ const auto controller_service_name = context.getProperty(prop.name);
+ if (!controller_service_name || controller_service_name->empty()) {
+return nullptr;
+ }
+
+ nonstd::expected service =
context.getControllerService(*controller_service_name,
minifi::core::className());
Review Comment:
this will need to be fixed on rebase: `nonstd` -> `std`
##
extension-framework/cpp-extension-lib/src/core/ProcessContext.cpp:
##
@@ -38,4 +38,17 @@ bool ProcessContext::hasNonEmptyProperty(std::string_view
name) const {
return MinifiProcessContextHasNonEmptyProperty(impl_,
utils::toStringView(name));
}
+nonstd::expected
ProcessContext::getControllerService(const std::string_view
controller_service_name,
+const std::string_view controller_service_class) const {
+ void* controller_service = nullptr;
Review Comment:
I think this is another thing that you'll fix during rebase without me
commenting, but this should be `MinifiControllerService*` instead of `void*`.
##
extension-framework/cpp-extension-lib/include/api/core/Resource.h:
##
@@ -145,4 +150,43 @@ void useProcessorClassDescription(Fn&& fn) {
fn(description);
}
+template
+void useControllerServiceClassDescription(Fn&& fn) {
+ std::vector> string_vector_cache;
+
+ const auto full_name = minifi::core::className();
+
+ std::vector class_properties =
utils::toProperties(Class::Properties, string_vector_cache);
+
+ MinifiControllerServiceClassDefinition description{.full_name =
utils::toStringView(full_name),
Review Comment:
I know it doesn't matter, but it hurts my OCD that this kind of object is
called a "description" everywhere, but the name of the class is "...Definition".
If it's not too much work to change it, it would be better if this was a
"definition" everywhere or a "description" everywhere, including the class name.
##
libminifi/test/libtest/unit/TestBase.cpp:
##
@@ -360,6 +360,27 @@ minifi::Connection*
TestPlan::addConnection(minifi::core::Processor* source_proc
return retVal;
}
+std::shared_ptr
TestPlan::addController(const std::string& name, const
std::shared_ptr& cs) {
Review Comment:
Why do we need this new version of `addController`? We only seem to be using
the old version.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Re: [PR] MINIFICPP-2764 Controller Service CPP API [nifi-minifi-cpp]
Copilot commented on code in PR #2152:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2152#discussion_r3022747423
##
extension-framework/cpp-extension-lib/src/core/ControllerServiceImpl.cpp:
##
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+#include "api/core/ControllerServiceImpl.h"
+
+#include
+
+#include
+#include
+#include
+#include
+
+#include "fmt/format.h"
+
+using namespace std::literals::chrono_literals;
+
+namespace org::apache::nifi::minifi::api::core {
+
+ControllerServiceImpl::ControllerServiceImpl(minifi::core::ControllerServiceMetadata
metadata)
+: metadata_(std::move(metadata)),
+ logger_(metadata_.logger) {
+ logger_->log_debug("Processor {} created with uuid {}", getName(),
getUUIDStr());
+}
+
+ControllerServiceImpl::~ControllerServiceImpl() {
+ logger_->log_debug("Destroying processor {} with uuid {}", getName(),
getUUIDStr());
Review Comment:
These log messages refer to a \"Processor\" even though this class is
`ControllerServiceImpl`. This is misleading during debugging/ops; please update
the messages to reference \"ControllerService\" (or \"controller service\")
consistently.
```suggestion
logger_->log_debug("ControllerService {} created with uuid {}", getName(),
getUUIDStr());
}
ControllerServiceImpl::~ControllerServiceImpl() {
logger_->log_debug("Destroying ControllerService {} with uuid {}",
getName(), getUUIDStr());
```
##
extension-framework/cpp-extension-lib/src/core/ControllerServiceImpl.cpp:
##
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+#include "api/core/ControllerServiceImpl.h"
+
+#include
+
+#include
+#include
+#include
+#include
+
+#include "fmt/format.h"
+
+using namespace std::literals::chrono_literals;
+
Review Comment:
In this new file, these headers and the chrono literals namespace are unused
(the file only uses `memory`, `string`, and logging). Removing unused includes
and `using namespace std::literals::chrono_literals;` will reduce compile time
and avoid misleading dependencies.
```suggestion
#include
#include
#include "fmt/format.h"
```
##
extension-framework/cpp-extension-lib/include/api/core/ControllerServiceImpl.h:
##
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+#include
+#include
+#include
+
+#include "ControllerServiceContext.h"
+#include "minifi-cpp/core/ControllerServiceMetadata.h"
+#include "minifi-cpp/utils/Id.h"
+#include "utils/SmallString.h"
+
+namespace org::apache::nifi::minifi::api {
+
+class Connection;
Review Comment:
``, the `Connectio
[PR] MINIFICPP-2764 Controller Service CPP API [nifi-minifi-cpp]
martinzink opened a new pull request, #2152: URL: https://github.com/apache/nifi-minifi-cpp/pull/2152 Thank you for submitting a contribution to Apache NiFi - MiNiFi C++. In order to streamline the review of the contribution we ask you to ensure the following steps have been taken: ### For all changes: - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message? - [ ] Does your PR title start with MINIFICPP- where is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character. - [ ] Has your PR been rebased against the latest commit within the target branch (typically main)? - [ ] Is your initial contribution a single, squashed commit? ### For code changes: - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? - [ ] If applicable, have you updated the LICENSE file? - [ ] If applicable, have you updated the NOTICE file? ### For documentation related changes: - [ ] Have you ensured that format looks appropriate for the output in which it is rendered? ### Note: Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
