You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/10/11 13:20:11 UTC

[GitHub] [dubbo] kezhenxu94 removed a comment on issue #3585: [DISCUSSION] Make filter totally asynchronous and event-driven.

kezhenxu94 removed a comment on issue #3585:
URL: https://github.com/apache/dubbo/issues/3585#issuecomment-469687420


   I'm wondering:
   - whether the proposed definition will result to the [Callback Hell](https://en.wiktionary.org/wiki/callback_hell), many programming languages tried to avoid **Callback Hell** such as `Future` in Java and `Promise` in Javascript
   - and the proposed definition seems make it difficult to synchronous calls (in case that users need it, let's leave it possible for synchronous calls)
   
   Can we borrow the design from The Netty Project, say returning a `org.apache.dubbo.filter.Future` that is declared like below:
   
   ```java
   class Future<T> {
     T get(); // wait for the result synchronously
     void onComplete(SomeContext c); // asynchronously
     void onSend(SomeContext c); // asynchronously
     void onError(SomeContext c); // asynchronously
     // ... other callbacks
   }
   ```
   
   then users can do something like this:
   ```java
   Filter filter = ...;
   Future f = filter.invoke(...);
   // if synchronous call is needed
   f.get();
   // if asynchronous call is needed
   f.onSend(context -> { /* lambda */ });
   f.onError(context -> { /* lambda */ });
   // ... others
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org