// WithRetryIfNeeded to check if there is a retryer can be used and if current call can retry.
// When the retry condition is satisfied, use retryer to call
WithRetryIfNeeded to check if there is a retryer can be used and if current call can retry.
When the retry condition is satisfied, use retryer to call
// WithRetryIfNeeded to check if there is a retryer can be used and if current call can retry . // When the retry condition is satisfied use retryer to call
func (rc *Container) WithRetryIfNeeded(ctx context.Context, rpcCall RPCCallFunc, ri rpcinfo.RPCInfo, request interface{}) (recycleRI bool, err error) {
	retryer := rc.getRetryer(ri)
	if retryer == nil {
		if _, err = rpcCall(ctx, nil); err == nil {
			return true, nil
		}
		return false, err
	}
	if msg, ok := retryer.AllowRetry(ctx); !ok {
		if _, err = rpcCall(ctx, retryer); err == nil {
			return true, err
		}
		if msg != "" {
			retryer.AppendErrMsgIfNeeded(err, msg)
		}
		return false, err
	}
	var reqOp = ReqOpNo
	ctx = context.WithValue(ctx, CtxReqOp, &reqOp)
	return retryer.Do(ctx, rpcCall, ri, request)
}
func ( rc * Container ) WithRetryIfNeeded ( ctx context . Context , rpcCall RPCCallFunc , ri rpcinfo . RPCInfo , request interface { } ) ( recycleRI bool , err error ) { retryer := rc . getRetryer ( ri ) if retryer == nil { if _ , err = rpcCall ( ctx , nil ) ; err == nil { return true , nil } return false , err } if msg , ok := retryer . AllowRetry ( ctx ) ; ! ok { if _ , err = rpcCall ( ctx , retryer ) ; err == nil { return true , err } if msg != " " { retryer . AppendErrMsgIfNeeded ( err , msg ) } return false , err } var reqOp = ReqOpNo ctx = context . WithValue ( ctx , CtxReqOp , & reqOp ) return retryer . Do ( ctx , rpcCall , ri , request ) }
WithRetryIfNeeded to check if there is a retryer can be used and if current call can retry.
WithRetryIfNeeded to check if there is a retryer can be used and if current call can retry .
// case 1(default): no retry policy // case 2: setup retry policy, but not satisfy retry condition eg: circuit, retry times == 0, chain stop, ddl // case 3: retry // reqOp is used for req concurrent write