当前位置:网站首页>[ Kitex Source Code Interpretation ] Request to retry
[ Kitex Source Code Interpretation ] Request to retry
2022-08-09 19:02:00 【InfoQ】
Kitex
CloudWeGo Source Code Interpretation

Request retry
- If the connection fails to retry (the framework will retry by default)
- Retry on timeout
- Backup Request
Retry if the connection fails to be established
Timeout retry
- Confirm that your service is idempotent, and then enable retry
- Timeout retry will increase delay
usage
fp := retry.NewFailurePolicy()
// optional configuration, the number of retries, default 2, does not include the first request
fp.WithMaxRetryTimes(xxx)
// optional configuration, total time, including the first failed request andIf the time required to retry the request reaches the limited duration, subsequent retries will be stopped.
fp.WithMaxDurationMS(xxx)
// Close the link and stop (the entire downstream link will be retried normally, there is a risk of retry amplification, please be careful.)
fp.DisableChainRetryStop()
// Enable DDL abort
// This strategy is to judge whether retry is required from the timeout time of the link.
// Note that Kitex does not have this implementation built-in, you need to register the DDL func through retry.RegisterDDLStop(ddlStopFunc),
// Combined with the link timeout judgment, the implementation recommends that the timestamp andTimeout judgment.
fp.WithDDLStop()
// Backoff strategy, no backoff strategy by default
fp.WithFixedBackOff(fixMS int) // Fixed duration backoff
fp.WithRandomBackOff(minMS int, maxMSint) // random duration backoff
// enable retry fuse
fp.WithRetryBreaker(errRate float64)
// retry on the same node
fp.WithRetrySameNode()
cli, err := echo.NewClient(
"echo",
client.WithHostPorts("0.0.0.0:8888"),
client.WithFailureRetry(fp),
)
if err != nil {
log.Fatal(err)
}
for {
req := &api.Request{Message: "my request"}
resp, err := cli.Echo(context.Background(), req)
if err != nil {
log.Fatal(err)
}
log.Println(resp)
time.Sleep(time.Second)
}Backup Request
Note
DisableChainRetryStop
边栏推荐
- 智能工具管理系统
- 2.1、基于并行上下文注意网络的场景文本图像超分辨率
- The article details of the qiucode.cn website realize the code block can be copied by clicking the button
- B44 - Based on stm32 bluetooth intelligent voice recognition classification broadcast trash
- Vim practical skills_2. Normal mode and insert mode
- 央企施工企业数字化转型的灵魂是什么
- A40 - 基于51单片机的GSM模块优化设计
- 【服务器数据恢复】SAN LUN映射出错导致文件系统数据丢失的数据恢复案例
- B019 - 甲醛甲烷煤气温湿度时间测试仪
- DP 优化方法合集
猜你喜欢

国星光电吉利产业园项目主体结构全面封顶,将重点生产 RGB 小间距、Mini LED、TOP LED 等产品

产品结构设计优化模具简化结构总结

网络——数字数据编码

Became CTO, was killed by my boss in 6 months, I lost 10 million

成为CTO,6个月被老板干死,我损失了1000万

A42 - 基于51单片机的洗衣机设计
Optimization of a piece of JDBC code (Part 1)

<IDEA using tricks & & combined operation of common keys>

HR to get the entry date RP_GET_HIRE_DATE

B43 - 基于STM32单片机的自动视力检测仪
随机推荐
ceph部署
原油等特殊期货开户要求和豁免
2022年中国第三方证券APP创新专题分析
ceph2
Insert a number and sort "Suggested Favorites"
Sigrity PowerSI 特征阻抗和耦合度仿真
融云 x N 世界:构建无限用户实时交互的「元宇宙会场」
TMin - whether TMin overflows
中科院打脸谷歌:普通电脑追上量子优越性,几小时搞定原本要一万年的计算...
一键生成 API 文档的妙招
B49 - 基于STM32单片机的心率血氧检测与远程定位报警装置
智能家居控制系统的功能和特点
HR to get the entry date RP_GET_HIRE_DATE
价值10亿美元 美国向乌克兰提供单次最大规模安全援助
B44 - 基于stm32蓝牙智能语音识别分类播报垃圾桶
pgsql备份工具,哪个比较好?
The Chinese Academy of Sciences slaps Google in the face: ordinary computers catch up with quantum superiority, and can solve calculations that would have taken 10,000 years in a few hours...
想通这点,治好 AI 打工人的精神内耗
A51 - 基于STM32的DHT11和LCD显示串口通信仿真
反转链表的多种写法(武器库了属于是)