当前位置:网站首页>[ 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
边栏推荐
- 称重模块的分类及特点
- 冷冻电镜聚类中心(2D Class)粒子图像的解析
- IDEA启动缓慢原因(一)
- Print the star chart "Recommended Collection"
- OpenCV image transformation - histogram equalization
- <IDEA using tricks & & combined operation of common keys>
- LeetCode 413.等差数列划分
- 2022年中国第三方证券APP创新专题分析
- 110+ public professional datasets summarized
- WeChat developer tools error, prompt did not find the entrance to the app. The json file
猜你喜欢
称重模块的分类及特点
Smart Light Pole Gateway Smart Transportation Application
视频聊天源码——一对一直播如何提高直播质量?
【嵌入式入门篇】嵌入式0基础沉浸式刷题篇1
uniapp project construction
Functions and Features of Smart Home Control System
ceph部署
B48 - 基于51单片机的学生管理门禁系统设计
【服务器数据恢复】SAN LUN映射出错导致文件系统数据丢失的数据恢复案例
Leetcode 算法面试冲刺 热题 HOT 100 刷题(406 416 437 438 448)(六十九)
随机推荐
qiucode.cn网站之文章详情实现代码块可点击按钮进行复制
【开源教程4】疯壳·开源编队无人机-OPENMV 脚本烧写
使用SourceTree添加SSH公钥并克隆码云项目(笔记整理篇)
【嵌入式入门篇】嵌入式0基础沉浸式刷题篇1
DP 优化方法合集
微信开发者工具程序开发好后,不报错,但是黑屏「建议收藏」
【教程3】疯壳·ARM功能手机-整板资源介绍
【燃】是时候展现真正的实力了!一文看懂2022华为开发者大赛技术亮点
NFT+IDO预售代币合约模式系统开发
视频聊天源码——一对一直播如何提高直播质量?
B46 - STM32太阳能充电智能心率监测骑行仪
云服务的分类和应用
CocosCreator接入微信小游戏
【服务器数据恢复】SAN LUN映射出错导致文件系统数据丢失的数据恢复案例
LeetCode 413.等差数列划分
Became CTO, was killed by my boss in 6 months, I lost 10 million
Codeforces Round #808 (Div. 2)||Precipitation
日志定期压缩、清除
中科院打脸谷歌:普通电脑追上量子优越性,几小时搞定原本要一万年的计算...
Apple Developer Account Apply for D-U-N-S Number