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

RFC add retry attribute (WP-828) #483

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

vsolovei-smartling
Copy link
Contributor

@vsolovei-smartling vsolovei-smartling commented Sep 6, 2023

I've expected more from attributes. I'm kind of on the fence regarding this one.
Looking back at our previous conversations regarding retries (#342 (comment), #355 (comment)) I feel like I was not explicit enough.
The choice of creating ApiWrapperWithRetries is due to the reason that we can't really proxy requests from one class to another. We have magic __call that is triggered when invoking inaccessible methods in an object context, but our methods are accessible, they're public. Making them private and relying on __call would open another can of worms, I really dislike it as an option, the comment from 7 years old still stands strong. __invoke is called when a script tries to call an object as a function e.g. (new ApiWrapper('Hello'), so not applicable.
Then come the attributes themselves. Having #[Retry] before a method call for a programmer coming from Java would look like, oh, hey, great, this will retry. It will not. Attribute names and their arguments are resolved to a class and the arguments are passed to its constructor, when an instance of the attribute is requested through the Reflection API. So we still need some underlying class to work the attributes.
P. S.: No, it's not possible to add an attribute to an interface.
P. P. S.: On ApiWrapperWithRetries implements ApiWrapperInterface vs ApiWrapperWithRetries extends ApiWrapper implements was chosen due to the fact that having #[Retry] before a method could seem that the retry will happen. In the implements approach, a developer would be forced to update ApiWrapperWithRetries, if it would extend ApiWrapper, the margin of error is greater, as a developer would most likely update only ApiWrapper and then some time later we would discover that no retries are in fact happening.

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