You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "lordgamez (via GitHub)" <gi...@apache.org> on 2024/05/06 10:42:30 UTC
Re: [PR] MINIFICPP-2295 Add SSLContextService support for NiFi Python processors [nifi-minifi-cpp]
lordgamez commented on code in PR #1762:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1762#discussion_r1590828391
##########
extensions/python/types/PyProcessContext.cpp:
##########
@@ -104,6 +107,30 @@ PyObject* PyProcessContext::getStateManager(PyProcessContext* self, PyObject*) {
return object::returnReference(context->getStateManager());
}
+PyObject* PyProcessContext::getControllerService(PyProcessContext* self, PyObject* args) {
+ auto context = self->process_context_.lock();
+ if (!context) {
+ PyErr_SetString(PyExc_AttributeError, "tried reading process context outside 'on_trigger'");
+ return nullptr;
+ }
+
+ const char* controller_service_name = nullptr;
+ const char* controller_service_type = nullptr;
+ if (!PyArg_ParseTuple(args, "s|s", &controller_service_name, &controller_service_type)) {
+ throw PyException();
+ }
+
+ if (auto controller_service = context->getControllerService(controller_service_name)) {
+ std::string controller_service_type_str = controller_service_type;
+ if (controller_service_type_str == "SSLContextService") {
+ auto ssl_ctx_service = std::dynamic_pointer_cast<controllers::SSLContextService>(controller_service);
+ return object::returnReference(std::weak_ptr(ssl_ctx_service));
+ }
+ }
Review Comment:
Updated the titles, unfortunately all python bindings use static function definitions so no logger object is present to log the errors, and we should not throw an exception here, only return a NONE object like NiFi does.
--
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: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org