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

CompletableFuture<T> support for GenericService. #3163

Closed
xcorpio opened this issue Jan 7, 2019 · 9 comments
Closed

CompletableFuture<T> support for GenericService. #3163

xcorpio opened this issue Jan 7, 2019 · 9 comments
Assignees

Comments

@xcorpio
Copy link

xcorpio commented Jan 7, 2019

泛化调用中

public interface GenericService {

    Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException;

}

这里可不可以异步调用返回个Future。我的工具实现会有多个 ReferenceConfig 缓存,我可以单独再用一个线程池来作为 $invoke 的执行上下文。但每个 ReferenceConfig 好像都有一组线程来维持,这个本身能不能异步调用?

@carryxyh
Copy link
Member

carryxyh commented Jan 8, 2019

应该是可以的,不过我需要验证一下效果,但是需要改造一下GenericService接口。
可能将来会长这样:

public interface GenericService {

    Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException;

    CompletableFuture<Object> $invokeAsync(String method, String[] parameterTypes, Object[] args) throws GenericException;
}

@xcorpio
Copy link
Author

xcorpio commented Jan 8, 2019

OK,期待...

@carryxyh carryxyh self-assigned this Jan 9, 2019
@manzhizhen
Copy link

I was suddenly more curious at the time that the GenericService did not implement asynchronous calls? Haha

@xiangxiuhui
Copy link

应该是可以的,不过我需要验证一下效果,但是需要改造一下GenericService接口。
可能将来会长这样:

public interface GenericService {

    Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException;

    CompletableFuture<Object> $invokeAsync(String method, String[] parameterTypes, Object[] args) throws GenericException;
}

oninvoke、onreturn、onthrow 也要支持下 GenericService
例如下面判断:
final Method onInvokeMethod = (Method) StaticContext.getSystemContext().get(StaticContext.getKey(invoker.getUrl(), invocation.getMethodName(), Constants.ON_INVOKE_METHOD_KEY));
final Object onInvokeInst = StaticContext.getSystemContext().get(StaticContext.getKey(invoker.getUrl(), invocation.getMethodName(), Constants.ON_INVOKE_INSTANCE_KEY));

@chickenlj
Copy link
Contributor

public interface GenericService {

Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException;

CompletableFuture<Object> $invokeAsync(String method, String[] parameterTypes, Object[] args) throws GenericException;

}

Is there any progress on this feature?

@carryxyh
Copy link
Member

@chickenlj
Hi, I am very sorry that I have been procrastinating for a long time.
I will try to solve this problem this week. If it's more complicated, I'll discuss a scenario on the mailing list.

@chickenlj
Copy link
Contributor

@carryxyh No hurry, if you don't get enough time maybe I can give it a try. Just make sure we don't spend too much time repeating this issue.

@chickenlj chickenlj changed the title 使用泛化调用中如何使用异步 CompletableFuture<T> support for GenericService. Mar 12, 2019
@carryxyh
Copy link
Member

Simple pr for this issue:
#3637

Would u pls have a review?

@chickenlj
Copy link
Contributor

I am on it.

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

No branches or pull requests

6 participants