-
Notifications
You must be signed in to change notification settings - Fork 26.6k
Closed
Description
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:
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.
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?
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
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels