Skip to content

[DISCUSSION] Make filter totally asynchronous and event-driven. #3585

@chickenlj

Description

@chickenlj

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

Metadata

Metadata

Assignees

No one assigned

    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