longkai / essays

Think fast, talk smart, write more.
https://xiaolongtongxue.com
Creative Commons Attribution 4.0 International
28 stars 11 forks source link

articles/2021/how-does-go-handle-http-request-timeout-and-cancel #9

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Go 是如何处理 HTTP 请求超时和取消的 - 小龙同学

本文通过解决一个线上告警问题,查看了go的http库是如何实现超时和取消的,最后总结了在go里面通用的超时处理方法。

https://www.xiaolongtongxue.com/articles/2021/how-does-go-handle-http-request-timeout-and-cancel

liuyu121 commented 2 years ago

hi 您好

请教个 case,配置了 timeout(比如 1s),但是在 Do 执行开始、结束后打点,发现执行时间大于 1s(如7s 、20s 甚至更长时间),这种一般是原因呀

longkai commented 2 years ago

hi 您好

请教个 case,配置了 timeout(比如 1s),但是在 Do 执行开始、结束后打点,发现执行时间大于 1s(如7s 、20s 甚至更长时间),这种一般是原因呀

方便看下demo吗