-
Notifications
You must be signed in to change notification settings - Fork 26.4k
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 @Async from core framework. #3095
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3095 +/- ##
===========================================
- Coverage 63.52% 63.5% -0.02%
Complexity 75 75
===========================================
Files 653 653
Lines 28208 28196 -12
Branches 4791 4790 -1
===========================================
- Hits 17918 17906 -12
- Misses 8025 8027 +2
+ Partials 2265 2263 -2
Continue to review full report at Codecov.
|
@chickenlj would be possible to explain for mine understanding purpose moving @Asynch from core to side project? |
public static boolean hasGeneratedFuture(Method method) { | ||
return method.isAnnotationPresent(AsyncFor.class) && hasFutureReturnType(method); | ||
} | ||
|
||
public static boolean isFutureReturnType(Invocation inv) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an thought should we consider this name to ** isReturnTypeFuture** instead of isFutureReturnType
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
@khanimteyaz Thanks for your attention, I will try to explain. As you may have noticed, we support a service definition with a CompletableFuture as the return type. public interface AsyncService {
CompletableFuture<String> sayHello(String name);
} But this is newly introduced in 2.7.0, which means, there would be many legacy services that can not leverage this feature. Because if they change the service definition (the interface definition) they will have to reimplement their service to meet the new definition. public interface GreetingsService {
String sayHi(String name);
} To be able to call this service asynchronously, they have to use // the invoke will return null immediately
greetingsService.sayHi("world");
// get the Future instance, the future will get notified once the result returns.
Future<String> future = RpcContext.getContext().getFuture(); Annotation @AsyncFor is a mechanism I introduced to simplify the process for those legacy services, you can refer to here for how it works. But now, as long as I realized we have supported java 8, we can use the default method to avoid generating a new class. Here is the new way I have come up with, this is what mean by saying `move the @AsyncFor from core to side project '. This way, this would become a convenient solution we provide but not a mandatory solution provided in core. |
@chickenlj Thanks a lot for the details. Appreciate it. I will give a look into this PR. |
This looks to fine ok to me. Thinking loud here (please correct me if I am wrong here). As here we are enabling dubbo consumer to make async call to service method, but to achieve this, service provider has to define the stub with CompletableFuture. Here whether a consumer can make a async call depends on whether service developer has enabled service interface with CompletableFuture or not in some form. The decision of communication mode (async or async) is consumer choice. So thinking, how can we make our provider and consumer independent or each other in this context. e.g. here an an analogy I am using to provide the approach @chickenlj Do you is there something we can do now or in future? |
This is a good point @khanimteyaz, I think I got what you want to express. Maybe we can also provide a utility method or sth like that. I am on a new year's vacation now, I will think about it as soon as I come back to work. |
By the way, the implementation of the async feature has been an enhncent or patch effort based on the legacy code. I think it definitely deserves an refactor.
Given that hou have put forward many constructive suggestions recently, which are of great help to us. It would be great if you've got some experience or you'd like to take a look at this part. |
I will merge this PR to prepare for the current release. |
@chickenlj Thanks for your detail information. I will try my best to suggest something which if there is something good I can comeup. Thanks for your appreciation. |
Looking forward to it. |
* remove @async from core framework. * refactor method name to isReturnFuture
What is the purpose of the change
move @AsyncFor from core framework to side project.
Brief changelog
remove @AsyncFor, call async counterpart directly.
Verifying this change
see dubbo/dubbo-samples
Follow this checklist to help us incorporate your contribution quickly and easily:
[Dubbo-XXX] Fix UnknownException when host config not exist #XXX
. Each commit in the pull request should have a meaningful subject line and body.mvn clean install -DskipTests=false
&mvn clean test-compile failsafe:integration-test
to make sure unit-test and integration-test pass.