dubbo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chickenlj (GitHub) <git...@apache.org>
Subject [GitHub] [incubator-dubbo] chickenlj opened issue #3585: [DISCUSSION] Make filter totally asynchronous and event-driven.
Date Fri, 01 Mar 2019 09:36:23 GMT
Recently, I am thinking of making the whole invoker chain inside Dubbo asynchronous, event-driven.
And I believe that `Filter` can be changed to better adapt to the new model.

Before 2.7.0, you can find the definition of Filter was completely synchronous:

```java
public interface Filter {
    Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
       // before
        Result result = invoker.invoke(invocation);
       // after
      return result;
    }
}
```

In 2.7.0, a callback `onResponse` was added to allow users to handle the async value when
result returns.

```java
public interface Filter {
   Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
   }

   void onResponse(Result result, Invoker<?> invoker, Invocation invocation) {
        // biz return
    }
}
```

Now, how about the following definition, totally asynchronous and event-driven?

```java
public interface Filter {
   void onSend(Invocation invocation) {
     // before invoke, throw exception to terminate 
    }

   void onResponse(Result result, Invoker<?> invoker, Invocation invocation) {
        // biz return successfully
    }

   void onError(Throwable e) throws RpcException{
        // biz throw exception
    }
}
```

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


Mime
View raw message