fgerlits commented on code in PR #1762:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1762#discussion_r1584692377
##########
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:
Since we only support `SSLContextService` for now, I think we should change
the titles (commit, Jira, PR) to reflect this, eg. "Add SSLContextService
support for NiFi python processors".
Also, we could log an error or warning here when the requested controller
service type is something other than `SSLContextService`.
--
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]