https://github.com/googs1025/gin-with-limiter
基于gin框架实现限流算法
https://github.com/googs1025/gin-with-limiter
Last synced: about 2 months ago
JSON representation
基于gin框架实现限流算法
- Host: GitHub
- URL: https://github.com/googs1025/gin-with-limiter
- Owner: googs1025
- Created: 2022-09-29T15:08:49.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-31T16:40:07.000Z (almost 2 years ago)
- Last Synced: 2025-01-30T08:28:51.160Z (4 months ago)
- Language: Go
- Size: 194 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
## 基于gin 实现限流算法
### 项目目录
```
├── go.mod
├── go.sum
├── main.go // gin server 路由
└── src // 项目主逻辑
├── Bucket.go // 令牌桶算法
├── ip_limit.go // 实现ip限流器(基于令牌桶、LRU都有实现)
├── limit.go // 普通限流器
├── listCache.go // LRU算法
├── listCache_test.go
├── paramlimit.go // 请求参数限流器
└── test // 简单测试文件
└── testlist.go```
### 令牌桶
#### 1. 建立桶结构
```
1.桶容量
2.当前桶有多少令牌
3.互斥锁
```