chenBright opened a new issue, #2134:
URL: https://github.com/apache/brpc/issues/2134

   **Is your feature request related to a problem? (你需要的功能是否与某个问题有关?)**
   
某些场景下(机器cpu负载高、服务启动时需要预热限制请求量),上层业务希望有能力进行访问控制,在ProcessXXXRequest中拒绝请求,不让请求走到回调方法中。
   
   **Describe the solution you'd like (描述你期望的解决方法)**
   提供一个Interceptor基类,用户继承该基类,并实现accept方法。
   ```c++
   class Interceptor {
   public:
       virtual bool Accept(
           const Controller* cntl,
           int& error_code,
           std::string& error_txt) const { return true; }
    
       virtual ~Interceptor() {}
   };
   ```
   
   提供全局的注册函数用于注册拦截器。
   ```c++
   int RegisterInterceptor(Interceptor* interceptor);
   ```
   
   在设置完method后调用用户注册的拦截器,用户根据controller的信息来判断是否拦截。
   
https://github.com/apache/brpc/blob/d587bd10d84f397bc099e41a07826ddc7de55ab5/src/brpc/policy/baidu_rpc_protocol.cpp#L462-L464
   
   **Describe alternatives you've considered (描述你想到的折衷方案)**
   
   
   **Additional context/screenshots (更多上下文/截图)**
   
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to