Skip to content

CompletableFuture<T> support for GenericService. #3163

Closed

Description

@xcorpio

泛化调用中

public interface GenericService {

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

}

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

Activity

  1. carryxyh commented on Jan 8, 2019

    @carryxyh
    Member

    应该是可以的,不过我需要验证一下效果,但是需要改造一下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;
    }
    
  2. xcorpio commented on Jan 8, 2019

    @xcorpio
    Author

    OK,期待...

  3. self-assigned this
    on Jan 9, 2019
  4. manzhizhen commented on Jan 15, 2019

    @manzhizhen

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

  5. xiangxiuhui commented on Jan 29, 2019

    @xiangxiuhui

    应该是可以的,不过我需要验证一下效果,但是需要改造一下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));

  6. chickenlj commented on Mar 12, 2019

    @chickenlj
    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?

  7. carryxyh commented on Mar 12, 2019

    @carryxyh
    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.

  8. chickenlj commented on Mar 12, 2019

    @chickenlj
    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.

  9. changed the title [-]使用泛化调用中如何使用异步[/-] [+]CompletableFuture<T> support for GenericService.[/+] on Mar 12, 2019
  10. carryxyh commented on Mar 12, 2019

    @carryxyh
    Member

    Simple pr for this issue:
    #3637

    Would u pls have a review?

  11. chickenlj commented on Mar 12, 2019

    @chickenlj
    Contributor

    I am on it.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions