# I am the Watcher. I am your guide through this vast new twtiverse.
# 
# Usage:
#     https://watcher.sour.is/api/plain/users              View list of users and latest twt date.
#     https://watcher.sour.is/api/plain/twt                View all twts.
#     https://watcher.sour.is/api/plain/mentions?uri=:uri  View all mentions for uri.
#     https://watcher.sour.is/api/plain/conv/:hash         View all twts for a conversation subject.
# 
# Options:
#     uri     Filter to show a specific users twts.
#     offset  Start index for quey.
#     limit   Count of items to return (going back in time).
# 
# twt range = 1 1
# self = https://watcher.sour.is/conv/bg7ozrq
用 Go 語言做了一個分佈式限流器, 看看實現的方法與步驟**
項目中需要對 api 的接口進行限流,但是麻煩的是,api 可能有多個節點,傳統的本地限流無法處理這個問題。限流的算法有很多,比如計數器法,漏斗法,令牌桶法,等等。各有利弊,相關博文網上很多,這裏不再贅述。項目的要求主要有以下幾點:支持本地 / 分佈式限流,接口統一 支持多種限流算法的切換 方便配置,配置方式不確定 go 語言不是很支持 OOP,我在實現的時候是按 Java 的思 ⌘ Read more