技术阅读周刊,每周更新。
历史更新
Prometheus vs. VictoriaMetrics (VM) | Last9
URL: https://last9.io/blog/prometheus–vs–victoriametrics/?ref=dailydev
对比了 Prometheus 和 VM 的区别考虑到和云原生的环境的兼容性,那 Prometheus 可能更合适些,毕竟是 CNCF 组织下的项目。 但如果考虑到性能、存储、资源占用性,VM 会更合适一些。
28 – Rust in Action: 10 Project Ideas to Elevate Your Skills
URL: https://rust–trends.com/newsletter/rust-in–action-10-project–ideas-to-elevate-your–skills/?ref=dailydev
这是一个 Rust 的 newsletter,介绍了十个项目 idea 可以提高你的 Rust 的水平,我看了下这些项目也不怎么限制语言,任何语言都可以尝试下。
Implementing a Bloom Filter in Go | by Francisco Escher | Nov, 2023 | ITNEXT
URL: https://itnext.io/bloom–filters–and–go-1d5ac62557de
Mastering Concurrency In Go — With Select, Goroutines, and Channels | by Yair Fernando | Better Programming
URL: https://betterprogramming.pub/concurrency-with–select–goroutines-and–channels-9786e0c6be3c
利用 select 多个 channel,来控制最早完成的线程,同时抛弃其他线程
func quickestApiResponse(functions []*Function) {
var articles []*Article
for _, function := range functions {
function.Run()
}
select {
case googleNewsResponse := <-google:
fmt.Printf("Source: %sn", googleNewsResponse.Source)
articles = googleNewsResponse.Articles
case freeNewsReponse := <-free:
fmt.Printf("Source: %sn", freeNewsReponse.Source)
articles = freeNewsReponse.Articles
}
fmt.Printf("Articles %vn", articles)
}
利用 time.After 返回的 channel,来控制达到超时时间后退出所有的线程
func main() {
ch := make(chan struct{}, 1)
go func() {
fmt.Println("do something...")
time.Sleep(4*time.Second)
ch<- struct{}{}
}()
select {
case <-ch:
fmt.Println("done")
case <-time.After(3*time.Second):
fmt.Println("timeout")
}
}
Context.Withtimeout 来控制超时
ch := make(chan string)
timeout, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
go func() {
time.Sleep(time.Second * 4)
ch <- "done"
}()
select {
case res := <-ch:
fmt.Println(res)
case <-timeout.Done():
fmt.Println("timout", timeout.Err())
}
-
https://last9.io/blog/prometheus–vs–victoriametrics/?ref=dailydev
-
https://rust-trends.com/newsletter/rust-in-action-10-project–ideas-to-elevate-your–skills/?ref=dailydev
-
https://betterprogramming.pub/concurrency-with-select-goroutines-and–channels-9786e0c6be3c
PS:最近也在更新视频号,也会有一些技术干货,动动小手帮主播点播关注
往期推荐
点分享
点收藏
点点赞
点在看
原文地址:https://blog.csdn.net/qq_18661793/article/details/134746219
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_30596.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!