go limiter:具有HTTP中间件的Go的超音速速率限制程序包 源码
限速器 该软件包提供了Go(Golang)中的速率限制器,适用于HTTP服务器和分布式工作负载。它是专为可配置性和灵活性而设计的,而不会影响吞吐量。 用法 创建一个商店。本示例使用内存存储: store , err := memorystore . New ( & memorystore. Config { // Number of tokens allowed per interval. Tokens : 15 , // Interval until tokens reset. Interval : time . Minute , }) if err != nil { log . Fatal ( err ) } 通过在商店上调用Take()来确定限制: ctx := context . Background () // key is the unique valu
下载地址
用户评论