Skip to content

refactor: Async recursive handler - #461

Closed
matthieubosquet wants to merge 1 commit into
masterfrom
change/refactor-async-recursive-handler
Closed

matthieubosquet wants to merge 1 commit into
masterfrom
change/refactor-async-recursive-handler

Conversation

@matthieubosquet

@matthieubosquet matthieubosquet commented Jan 2, 2021 •

Copy link
Copy Markdown
Contributor

This allows following the regular pattern of canHandle/handle with handlers that are recursive.
It fixes the Waterfall. I think I can simplify the Sequence one as well if this is ok.

@RubenVerborgh

Copy link
Copy Markdown
Member

@matthieubosquet What problem are we solving here—do you have an example of what is broken with the waterfall and what needs fixing?

In general, I would suggest to always create an issue first to describe the problem, and then have a PR that is a solution.

@matthieubosquet

matthieubosquet commented Jan 2, 2021 •

Copy link
Copy Markdown
Contributor Author

In the WaterfallHandler, the canHandle and handle functions aren't really usable as is.
Because the handle function does perform the canHandle check and the canHandle function can't return the handler that can Handle the input.

Therefore they're just duplicating/misleading code here to conform to the interface, which seems wrong (they are not called and probably shouldn't ever, which also is misleading).
I like the handleSafe => canHandle + handle pattern.
I don't think we should have to deviate from it here.

@RubenVerborgh

Copy link
Copy Markdown
Member

In the WaterfallHandler, the canHandle and handle functions aren't really usable as is.

They are though. They work and conform to the contract.

Therefore they're just duplicating/misleading code here to conform to the interface, which seems wrong.

So is the issue that there is a performance overhead?
That's why we have handleSafe.

I like the handleSafe => canHandle + handle pattern.

Me too 🙂 We're not breaking it.

I don't think we should have to deviate from it here.

We're not deviating.

  • canHandle: should you be the one handling it?
  • handle: well, do it then!
  • handleSafe: the above 2 combined in one call

This PR would make all handlers deviate for one specific performance optimization, for which a solution already exists.

@matthieubosquet

Copy link
Copy Markdown
Contributor Author

I think you're right Ruben.

Thanks for the explanation! :)

@jvherweg
jvherweg deleted the change/refactor-async-recursive-handler branch January 13, 2021 13:34
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.

2 participants