You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by "chenBright (via GitHub)" <gi...@apache.org> on 2023/02/23 12:41:15 UTC

[I] 支持自定义服务端拒绝(拦截器) (brpc)

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: dev-unsubscribe@brpc.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


Re: [I] 支持自定义服务端拒绝(拦截器) (brpc)

Posted by "chenBright (via GitHub)" <gi...@apache.org>.
chenBright commented on issue #2134:
URL: https://github.com/apache/brpc/issues/2134#issuecomment-1443181662

   好的,那提供一个服务维度的拦截器。用户可以通过ServerOptions设置。


-- 
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: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


Re: [I] 支持自定义服务端拒绝(拦截器) (brpc)

Posted by "serverglen (via GitHub)" <gi...@apache.org>.
serverglen commented on issue #2134:
URL: https://github.com/apache/brpc/issues/2134#issuecomment-1442830669

   > > 提供全局的注册函数用于注册拦截器。
   > > ```c++
   > > int RegisterInterceptor(Interceptor* interceptor);
   > > ```
   > 
   > 这个是不是可以放在ServerOptions中?
   
   赞同,我也理解一个拦截器能满足需求,而且拦截器是服务维度的,不同服务可以实现不同的拦截器。


-- 
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: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


Re: [I] 支持自定义服务端拒绝(拦截器) (brpc)

Posted by "chenBright (via GitHub)" <gi...@apache.org>.
chenBright commented on issue #2134:
URL: https://github.com/apache/brpc/issues/2134#issuecomment-1447794047

   > 回包的时候也加个拦截器吧
   
   @guodongxiaren #1433 这个pr是不是已经实现这个特性了?


-- 
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: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


Re: [I] 支持自定义服务端拒绝(拦截器) (brpc)

Posted by "chenBright (via GitHub)" <gi...@apache.org>.
chenBright closed issue #2134: 支持自定义服务端拒绝(拦截器)
URL: https://github.com/apache/brpc/issues/2134


-- 
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: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


Re: [I] 支持自定义服务端拒绝(拦截器) (brpc)

Posted by "wwbmmm (via GitHub)" <gi...@apache.org>.
wwbmmm commented on issue #2134:
URL: https://github.com/apache/brpc/issues/2134#issuecomment-1442821129

   一个拦截器应该能满足需求了吧?


-- 
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: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


Re: [I] 支持自定义服务端拒绝(拦截器) (brpc)

Posted by "guodongxiaren (via GitHub)" <gi...@apache.org>.
guodongxiaren commented on issue #2134:
URL: https://github.com/apache/brpc/issues/2134#issuecomment-1445892824

   回包的时候也加个拦截器吧


-- 
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: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


Re: [I] 支持自定义服务端拒绝(拦截器) (brpc)

Posted by "wwbmmm (via GitHub)" <gi...@apache.org>.
wwbmmm commented on issue #2134:
URL: https://github.com/apache/brpc/issues/2134#issuecomment-1442694212

   > 提供全局的注册函数用于注册拦截器。
   > 
   > ```c++
   > int RegisterInterceptor(Interceptor* interceptor);
   > ```
   
   这个是不是可以放在ServerOptions中?


-- 
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: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


Re: [I] 支持自定义服务端拒绝(拦截器) (brpc)

Posted by "chenBright (via GitHub)" <gi...@apache.org>.
chenBright commented on issue #2134:
URL: https://github.com/apache/brpc/issues/2134#issuecomment-1442764392

   > > 提供全局的注册函数用于注册拦截器。
   > > ```c++
   > > int RegisterInterceptor(Interceptor* interceptor);
   > > ```
   > 
   > 这个是不是可以放在ServerOptions中?
   
   ServerOptions加个std::vector<Interceptor>,是不是不太好呀?
   或者ServerOptions加的是Interceptor*,只允许注册一个拦截器。用户的所有策略都在这个拦截器里实现?


-- 
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: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org