mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-24 13:18:53 +08:00
放宽设备登记限流至每用户每小时一百次 (#1421)
This commit is contained in:
4 files changed
+6
-6
No files matched your search
@@ -699,7 +699,7 @@ paths:
|
||||
'400': {$ref: '#/components/responses/ResourceError400'}
|
||||
'401': {$ref: '#/components/responses/Unauthorized'}
|
||||
'409': {description: endpoint_limit_exceeded 或 endpoint_revoked}
|
||||
'429': {description: 设备登记每用户每小时最多十次,遵守 Retry-After}
|
||||
'429': {description: 设备登记每用户每小时最多一百次,遵守 Retry-After}
|
||||
'503': {$ref: '#/components/responses/EndpointUnavailable'}
|
||||
get:
|
||||
summary: 读取当前用户的单个端点
|
||||
|
||||
@@ -198,7 +198,7 @@ func (p *Postgres) RegisterDevice(ctx context.Context, user, machine string, r R
|
||||
if err != nil {
|
||||
return Endpoint{}, err
|
||||
}
|
||||
if count > 10 {
|
||||
if count > 100 {
|
||||
return Endpoint{}, fault{"rate_limited"}
|
||||
}
|
||||
return p.transaction(ctx, user, func(q *sqlc.Queries, tx pgx.Tx) (sqlc.Endpoint, error) {
|
||||
|
||||
@@ -143,10 +143,10 @@ func TestDeviceRegistration(t *testing.T) {
|
||||
|
||||
func TestDeviceRegistrationRateLimit(t *testing.T) {
|
||||
f := newFixture(t)
|
||||
for range 10 {
|
||||
for range 100 {
|
||||
code, data := call(t, f, "PUT", "/endpoints/"+machineA, deviceBody, "owner")
|
||||
if code != 200 {
|
||||
t.Fatalf("十次登记以内不应限速: %d %s", code, data)
|
||||
t.Fatalf("一百次登记以内不应限速: %d %s", code, data)
|
||||
}
|
||||
}
|
||||
req, err := http.NewRequestWithContext(t.Context(), "PUT", f.server.URL+"/endpoints/"+machineA, strings.NewReader(deviceBody))
|
||||
@@ -160,7 +160,7 @@ func TestDeviceRegistrationRateLimit(t *testing.T) {
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != 429 || resp.Header.Get("Retry-After") == "" {
|
||||
t.Fatalf("第十一次登记应限速并给出等待时间: %d %s", resp.StatusCode, resp.Header.Get("Retry-After"))
|
||||
t.Fatalf("第一百零一次登记应限速并给出等待时间: %d %s", resp.StatusCode, resp.Header.Get("Retry-After"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -751,7 +751,7 @@ ResolveSession(user_id, session_header, parent_header)
|
||||
| 并发会话 | 每账号最多 2 个,会话内串行 |
|
||||
| 会话请求 | 每用户每分钟 60 次 |
|
||||
| 轮次请求 | 每用户每分钟 30 批、4 MiB |
|
||||
| 设备登记 | 每用户每小时 10 次 |
|
||||
| 设备登记 | 每用户每小时 100 次 |
|
||||
| 网关未知占位 | 每用户未补齐占位会话最多 1000 个 |
|
||||
| 重试 | 5 秒起,指数退避至 5 分钟并加抖动 |
|
||||
|
||||
|
||||
Reference in new issue
Block a user