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)

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
```

[ Full content available at: 
https://github.com/apache/incubator-dubbo/issues/3585 ]
This message was relayed via gitbox.apache.org for 
[email protected]

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to