Skip to content

MINIFICPP-1457 - Implement InputRequirements#1042

Closed
adam-markovics wants to merge 19 commits intoapache:mainfrom
adam-markovics:MINIFICPP-1457
Closed

MINIFICPP-1457 - Implement InputRequirements#1042
adam-markovics wants to merge 19 commits intoapache:mainfrom
adam-markovics:MINIFICPP-1457

Conversation

@adam-markovics
Copy link
Contributor

@adam-markovics adam-markovics commented Apr 6, 2021

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-XXXX where XXXX 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?
  • 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.


// ExecuteProcess Class
class ExecuteProcess : public core::Processor {
class ExecuteProcess : public core::Processor, public core::annotation::input::Forbidden {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should allow - the process to be executed can be speficied in flowfile attributes and whatnot

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it can be specified but it seems to me, that it won't be used, this might be a bug

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Input is also forbidden in NiFi, I will ask them what they think about this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ExecuteStreamCommand is the one in NiFi that accepts commands from an incoming flowfile. We don't have that (yet?).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, makes sense to differentiate the two, but that's definitely out of scope of this change.
Leave it as "allowed" for now, later we can align the processors to NiFi

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

@lordgamez lordgamez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@szaszm szaszm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the PR looks functional, and the functionality is very appreciated, I have issues with the design. See my comment below.


template <typename T>
struct Annotation {
const T value_;
Copy link
Member

@szaszm szaszm Apr 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implicitly disables move, because it's a non-static const data member, inherited by the . It should be static constexpr IMO. It also pollutes the scope of derived classes with an overly generic name value_, because it's all used through inheritance.

I don't like using inheritance for this purpose. I would prefer if classes could just declare their requirements by creating a type alias of a well known name, like struct MyProcessor : Processor { using input_requirements = annotation::input::required; };. In other words, using type traits to check this at compile-time, with no runtime cost, less invasive dependencies and less pollution.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compile-time would be a nice touch, but I don't see how could we verify at compile-time that a processor requiring inputs actually gets some input connections, also wouldn't this require the code to a) either cast all processors to their most derived type b) reimplement the input requirement validation for all processor types?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree with the member pollution concern, we could get rid of the value_ altogether by trying successive dynamic_casts to Required, Allowed and Forbidden

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point about the compile-time requirements, I didn't think about not having the static type being the most derived type. As a runtime-friendly alternative, we could avoid using inheritance by introducing a new virtual function, something along the lines of getInputRequirements() const, or passing the enum value to the Processor base constructor for storage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants