支持内存的流控实现

This commit is contained in:
2024-06-20 20:58:15 +08:00
parent 7c31a1111e
commit d509496d72
4 changed files with 84 additions and 0 deletions

27
memory_test.go Normal file
View File

@ -0,0 +1,27 @@
// Package rate_limit ...
//
// Description : rate_limit ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 2024-06-20 20:55
package rate_limit
import (
"context"
"fmt"
"git.zhangdeman.cn/zhangdeman/rate_limit/define"
"testing"
)
func TestMemory_AllowN(t *testing.T) {
for i := 0; i < 10; i++ {
fmt.Println(MemoryClient.AllowN(context.Background(), &define.LimitConfig{
Key: "deman",
Total: 15,
Rate: 10,
TimeInterval: 10,
}, 8))
}
}