此篇為各筆記之整理,非原創內容,資料來源可見下方連結與文後參考資料:
Understanding the context package
@ rungo
pkg/context @ pkg.go.dev
context package
最重要的就是處理多個
goroutine
的情況,特別是用來送出取消或結束的
signal。
我們可以在一個 goroutine
中建立
Context
物件後,傳入另一個
goroutine;另一個 goroutine
即可以透過
Done()...
2020年11月16日
[go-pkg] time/rate package
time/rate @
go.pkg
Golang 標準庫限流器 time/rate
使用介紹
Golang time/rate 限速器
@ 簡書
重要概念
在 Golang 中使用 Limiter
來控制在特定頻率內,某個事件是否允許被執行。這個
Limiter 是實作
Token Bucket
的方式來達到限流的目的,也就是會先設定:
...