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

Expose Executer via factory class #194

Open
wants to merge 9 commits into
base: 1.x
Choose a base branch
from
Open

Conversation

skydiablo
Copy link

@skydiablo skydiablo commented Mar 1, 2022

this allows to extend the give classes and more flexible for own use.

…n classes and more flexible for owner use.
Copy link
Member

@clue clue left a comment

Choose a reason for hiding this comment

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

@skydiablo Thank you very much for looking into this and filing this PR!

I can definitely see some room for improvement for the ResolverInterface, but my biggest concern here is that adding a new method to an interfaces is inherently a BC break, as it will break all existing implementors of this interface.

We've had a related discussion in #159 (and others), so I wonder how much is really gained by having this as part of the ResolverInterface instead of using the existing ExecutorInterface?

(I've added minor remarks below for completeness, but my main concern at the moment would be the BC break mentioned above.)

src/Resolver/Factory.php Outdated Show resolved Hide resolved
src/Resolver/Resolver.php Outdated Show resolved Hide resolved
src/Resolver/ResolverInterface.php Outdated Show resolved Hide resolved
tests/FunctionalResolverTest.php Outdated Show resolved Hide resolved
src/Resolver/ResolverInterface.php Outdated Show resolved Hide resolved
@skydiablo
Copy link
Author

my motivation is to benefit from the existing Resolver-Factory and also have access to the underlying executor, in detail to the query function. in the current implementation there is no way to get this in one shut, i have to copy-paste the complete factory class and inject my requirements.
with this changes, i can just extend the factory class and override the points to met my requirements.

@clue
Copy link
Member

clue commented Mar 2, 2022

my motivation is to benefit from the existing Resolver-Factory and also have access to the underlying executor, in detail to the query function. in the current implementation there is no way to get this in one shut […]

@skydiablo Very true, completely agree that this is needlessly complicated. Perhaps we can simplify this by simply exposing the ExecutorInterface from the Factory somehow? The ExecutorInterface can still be passed to the Resolver if you need to work with the ResolverInterfaec. This way, you should be able to invoke all methods using the same ExecutorInterface. WDYT?

@skydiablo
Copy link
Author

skydiablo commented Mar 2, 2022

@clue just expose an function like createExecuter for internal and external use in the Factory-Class? Or What about an new Factory-Class still for the Executer itself and Resolver-Factory can use this Factory internal itself or just extends the Executer-Factory?

@skydiablo skydiablo changed the title add low-level resolveQuery function Expose Executer via factory class Mar 2, 2022
@WyriHaximus WyriHaximus self-requested a review March 2, 2022 21:38
@clue
Copy link
Member

clue commented Mar 3, 2022

just expose an function like createExecuter for internal and external use in the Factory-Class?

Sounds about right, but just an idea at this point and we'd have to take a look at this more in-depth.

Or What about an new Factory-Class still for the Executer itself and Resolver-Factory can use this Factory internal itself or just extends the Executer-Factory?

Extending implies an "is a" relationship, not sure "ResolverFactory is a ExecutorFactory" is reasonable. Composition over inheritance?

Not sure a dedicated ExecutorFactory is worth the effort, especially since we've started moving away from factory classes where possible to improve DX. I agree that adding this as a method to the ResolverFactory might not be perfect, but perhaps might make sense from a KISS perspective?

@skydiablo
Copy link
Author

divide the two section should the best case and the last change does not have any BC breaks. in case of DI, nobody say you have to use a factory-class, it will just create for you the "best" case of composition.

src/Query/ExecutorFactory.php Outdated Show resolved Hide resolved
src/Query/ExecutorFactory.php Outdated Show resolved Hide resolved
use React\EventLoop\Loop;
use React\EventLoop\LoopInterface;

class ExecutorFactory
Copy link
Member

Choose a reason for hiding this comment

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

This pretty much creates what most end users need to use this component. IMHO using Factory as name tells enough, and since this object holds no state, we can make all methods static.

Copy link
Member

Choose a reason for hiding this comment

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

Never mind this comment's part on naming, missed that it is in the Query directory. But we can still make all methods static IMHO.

Copy link
Author

Choose a reason for hiding this comment

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

hm, yes it is possible.... @clue ???

Copy link
Member

Choose a reason for hiding this comment

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

No strong opinion here, but not sure I quite like the idea of going more into factory land. I understand it's not optimal, but perhaps adding a new method to the existing factory class helps reduce the API surface?

Copy link
Author

Choose a reason for hiding this comment

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

in respect to the upcoming DI/DX in react, a more granular distribution of classes give the best opportunity to combine it in more fancy ways and a test-case can be more precisely. so we should it keep in two classes. the static way can be interest but not really needed, i would it leave as it is ...

Copy link
Member

Choose a reason for hiding this comment

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

Been thinking about this over the weekend, and part of the issue of creating another factory is that we'd start putting them everywhere. And you have to start creating aliases for them if you use more than one. Not hard opinions here either.

Copy link
Author

Choose a reason for hiding this comment

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

as long as the reactPHP libs does not depend and implement an DI/DX container, a factory is a good alternate. later we can refactor to DI and can exchange or run in parallel mode.

@skydiablo
Copy link
Author

push :P

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

Successfully merging this pull request may close these issues.

None yet

3 participants