mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-10 11:19:50 +08:00
Fix/api key concurrency runtime miss (#309)
* test(cli): 覆盖 API key 并发等待与超时路径 * feat(scheduler): API key 并发饱和时等待可用槽位 * fix(proxy): 区分 API key 并发受限与真正的 runtime miss * fix(outcome): runtime miss 仅归因真实执行候选 * feat(api-keys): 统一 concurrent_limit 默认值与校验辅助 * feat(admin): 独立 Key 接口支持 concurrent_limit * feat(admin): 用户 API Key 路由支持 concurrent_limit * feat(public): 自助 API Key 路由支持 concurrent_limit * feat(import): 导入与存储层持久化 concurrent_limit * feat(frontend): 同步 API Key concurrent_limit 类型定义 * feat(frontend): 独立 Key 表单支持 concurrent_limit * feat(frontend): 管理员用户 API Key 表单支持 concurrent_limit * feat(frontend): 自助 API Key 页面支持 concurrent_limit * chore(fmt): 统一 runtime 归因相关 Rust 格式 * chore(fmt): 统一 admin API key 路由 Rust 格式 * chore(fmt): 统一 public 路由与相关测试 Rust 格式 * fix(test): 对齐 no-execution usage 归因断言 * test(middleware): 固定 access log tracing 用例线程模型 * fix(frontend): 提取用户 API Key payload 默认并发辅助 * fix(frontend): 保留用户 Key 的 concurrent_limit 默认值 * fix(api-keys): remove hardcoded concurrent limit default --------- Co-authored-by: fawney19 <[email protected]>
This commit is contained in:
@@ -679,6 +679,12 @@
|
||||
>
|
||||
{{ formatRateLimitSimple(apiKey.rate_limit) }}
|
||||
</Badge>
|
||||
<Badge
|
||||
variant="secondary"
|
||||
class="text-xs"
|
||||
>
|
||||
{{ formatConcurrentLimitSimple(apiKey.concurrent_limit) }}
|
||||
</Badge>
|
||||
</div>
|
||||
<div class="flex items-center gap-1 mt-0.5">
|
||||
<code class="text-xs font-mono text-muted-foreground">
|
||||
@@ -795,7 +801,7 @@
|
||||
{{ editingUserApiKey ? '编辑 API Key' : '创建 API Key' }}
|
||||
</h3>
|
||||
<p class="text-xs text-muted-foreground">
|
||||
{{ editingUserApiKey ? '更新用户 API Key 的名称和速率限制' : '为用户创建新的 API Key' }}
|
||||
{{ editingUserApiKey ? '更新用户 API Key 的名称、速率限制和并发限制' : '为用户创建新的 API Key' }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -834,6 +840,25 @@
|
||||
留空表示不限制
|
||||
</p>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<Label
|
||||
for="admin-user-key-concurrent-limit"
|
||||
class="text-sm font-medium"
|
||||
>并发限制</Label>
|
||||
<Input
|
||||
id="admin-user-key-concurrent-limit"
|
||||
:model-value="userApiKeyForm.concurrent_limit ?? ''"
|
||||
type="number"
|
||||
min="0"
|
||||
max="10000"
|
||||
class="h-10"
|
||||
placeholder="0 = 不限并发"
|
||||
@update:model-value="(v) => userApiKeyForm.concurrent_limit = parseNumberInput(v, { min: 0, max: 10000 })"
|
||||
/>
|
||||
<p class="text-xs text-muted-foreground">
|
||||
{{ editingUserApiKey ? '留空表示保持当前值,填 0 表示不限并发' : '留空表示不限并发,填 0 也表示不限并发' }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
@@ -1099,6 +1124,7 @@ const editingUserApiKey = ref<ApiKey | null>(null)
|
||||
const userApiKeyForm = ref({
|
||||
name: '',
|
||||
rate_limit: undefined as number | undefined,
|
||||
concurrent_limit: undefined as number | undefined,
|
||||
})
|
||||
|
||||
// 用户统计
|
||||
@@ -1253,6 +1279,13 @@ function formatCurrencyValue(value: number | null, nullLabel = '-'): string {
|
||||
return `$${value.toFixed(2)}`
|
||||
}
|
||||
|
||||
function formatConcurrentLimitSimple(concurrentLimit?: number | null): string {
|
||||
if (concurrentLimit == null || concurrentLimit === 0) {
|
||||
return '不限并发'
|
||||
}
|
||||
return `${concurrentLimit} 并发`
|
||||
}
|
||||
|
||||
function isNegativeWalletValue(value: number | null): boolean {
|
||||
return typeof value === 'number' && value < 0
|
||||
}
|
||||
@@ -1387,6 +1420,7 @@ function openCreateUserApiKeyDialog() {
|
||||
userApiKeyForm.value = {
|
||||
name: `Key-${new Date().toISOString().split('T')[0]}`,
|
||||
rate_limit: undefined,
|
||||
concurrent_limit: undefined,
|
||||
}
|
||||
editingUserApiKey.value = null
|
||||
showUserApiKeyFormDialog.value = true
|
||||
@@ -1397,6 +1431,7 @@ function openEditUserApiKeyDialog(apiKey: ApiKey) {
|
||||
userApiKeyForm.value = {
|
||||
name: apiKey.name || '',
|
||||
rate_limit: apiKey.rate_limit ?? undefined,
|
||||
concurrent_limit: apiKey.concurrent_limit ?? undefined,
|
||||
}
|
||||
showUserApiKeyFormDialog.value = true
|
||||
}
|
||||
@@ -1407,6 +1442,7 @@ function closeUserApiKeyFormDialog() {
|
||||
userApiKeyForm.value = {
|
||||
name: '',
|
||||
rate_limit: undefined,
|
||||
concurrent_limit: undefined,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1423,12 +1459,14 @@ async function submitUserApiKeyForm() {
|
||||
await usersStore.updateApiKey(selectedUser.value.id, editingUserApiKey.value.id, {
|
||||
name: userApiKeyForm.value.name,
|
||||
rate_limit: userApiKeyForm.value.rate_limit ?? 0,
|
||||
concurrent_limit: userApiKeyForm.value.concurrent_limit,
|
||||
})
|
||||
success('API Key已更新')
|
||||
} else {
|
||||
const response = await usersStore.createApiKey(selectedUser.value.id, {
|
||||
name: userApiKeyForm.value.name,
|
||||
rate_limit: userApiKeyForm.value.rate_limit ?? 0,
|
||||
concurrent_limit: userApiKeyForm.value.concurrent_limit,
|
||||
})
|
||||
newApiKey.value = response.key || ''
|
||||
showNewApiKeyDialog.value = true
|
||||
|
||||
Reference in New Issue
Block a user