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

Remove return type dependency of filter step #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sagikazarmark
Copy link
Contributor

We have already been talking about using exceptions in a workflow and we agreed we should keep their number low as exceptions require more resources. I am still opening this PR now, because I think we should remove the return type dependency from steps.

Thinking about filters: if a filter must be used too much times, then the workflow is possibly badly constructed. Big data feeds should be filtered as much as possible prior to processing with Port.

What do you think?

@@ -39,7 +40,7 @@ public function process($item, callable $next)
{
foreach (clone $this->filters as $filter) {
if (false === call_user_func($filter, $item)) {
return false;
throw new FilterException();
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not a good idea, this will decrease the performance a lot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would be happy with any alternative which does not mess with return values.

Copy link
Contributor

Choose a reason for hiding this comment

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

The thing is, i agree if we goes with good design this should throw an exception but if we decide to focus on performance this shouldn't be modified.

Is there any alternative to throw an exception? I really like good software design, but performance is also importance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure, I can't think of any clean solution, only ugly ones (with variables passed by reference at some point)

@ddeboer
Copy link
Member

ddeboer commented Nov 16, 2015

Thinking about filters: if a filter must be used too much times, then the workflow is possibly badly constructed. Big data feeds should be filtered as much as possible prior to processing with Port.

I don’t agree that if the filter is used on many (or all) items, the filtering should be done outside of Port. We have the filters exactly in order to enable users to filter and write their data in one workflow.

if we decide to focus on performance this shouldn't be modified.

One of the focus points of ddeboer/data-import was not performance per se, but rather using as little memory as possible. After all, when processing large amounts of data with PHP, memory can be a problem.

@sagikazarmark
Copy link
Contributor Author

Actually, I kind thought myself with this.

@Baachi is right, exceptions would be a huge performance hit, which we probably don't want, even if performance is not our number one priority.

Also, this exception is probably still too much filter specific, so I propose the following:

Define return status codes in the Step interface: SKIP (0), SUCCESS (1), FAILURE (-1) (for now). Steps should return these or null (actually I would even force to return one of these codes, otherwise it is treated as a failure, once we drop 5.x support in favour of 7.x, we could even return typehing for integer).

@Baachi
Copy link
Contributor

Baachi commented Nov 16, 2015

@sagikazarmark we can also use constants for that which have these values.

@sagikazarmark
Copy link
Contributor Author

In case it wasn't clear: I meant them to be constants with the given integer values. I would rather work with integer than string status codes.

@Baachi
Copy link
Contributor

Baachi commented Nov 16, 2015

Sounds good. 👍

Copy link

@Ijamb Ijamb left a comment

Choose a reason for hiding this comment

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

@``

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.

4 participants