chenBright commented on PR #2273:
URL: https://github.com/apache/brpc/pull/2273#issuecomment-1597044204
> > > > Hi,
> > > > Since `Retry_backoff_policy` or `Backoff_retry_policy` **IS A**
Retry policy, it is not a good idea that both policies exist in channel,
> > > > ```
> > > > , retry_policy(NULL)
> > > > , retry_backoff_policy(NULL)
> > > > ```
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > It is better that retry_backoff_policy inherits basic interface in a
manner of :
> > > > ```
> > > > class BackoffRetryPolicy : public RetryPolicy {
> > > > bool DoRetry(const Controller* controller) const {
> > > > // details in backoff policy
> > > > }
> > > > }
> > > > ```
> > >
> > >
> > > @thorneliu Good idea. Maybe These virtual functions can be added to
RetryPolicy with default implementation that the retry backoff feature is
turned off. In a manner of:
> > > ```c++
> > > class RetryPolicy {
> > > public:
> > > virtual ~RetryPolicy();
> > > virtual bool DoRetry(const Controller* controller) const = 0;
> > > virtual int32_t GetBackoffTimeMs(const Controller* controller, int
nretry,
> > > int64_t remaining_rpc_time_ms)
const { return 0; }
> > > virtual bool CanRetryBackoffInPthread() const { return false; }
> > > };
> > > ```
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > `FixedRetryBackoffPolicy` and `JitteredRetryBackoffPolicy` inherit
`RpcRetryPolicy` which implements the default rpc retry policy.
> >
> >
> > @thorneliu New implementationhas been updated. Could you spare some tine
to review it again and offer any additional input?
>
> Hi, 不好意思没有及时回复
>
> 我觉得最好是RetryPolicy的接口不添加 GetBackoffTimeMs 或CanRetryBackoffInPthread
>
> 我们是否可以做到,
>
> ```
> fooPolicy = new brpc::fooPolicy(arg1, arg2).
> channeloptions.retryPolicy = fooPolicy;
> ```
>
> 然后类似 BackoffTimeMs 这样的细节封装在各自的policy内部。基本的rpcRetryPolicy接口只暴露一个简单的
`DoRetry()` 方法?
https://github.com/apache/brpc/blob/f27fbb4989e1bb2542596049f0263f234b8afb17/src/brpc/controller.cpp#L630-L655
目前来看,好像不能只通过`DoRetry`实现backoff,框架中`DoRetry`的语义是是否要重试,如果是,还有一些工作要做:
``` c++
_current_call.OnComplete(this, _error_code, info.responded, false);
++_current_call.nretry;
```
如果在`DoRetry`中做backoff,这些工作也会被推迟,不太合适,还是做完这些工作再做backoff合适一些吧。而且用户要实现自定义backoff的话,就得需要十分清楚框架此处的实现(例如pthread上做backoff会阻塞pthread、_current_call.nretry还未加1、之前的rpc出现网络错误,socket被SetFailed的时机也推迟等),否则很容易会踩坑。
--
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]