Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,16 @@ PROBE_INTERVAL_MS=30000
PROBE_TIMEOUT_MS=5000

# Provider Endpoint Probing (always enabled)
# 功能说明:每 10 秒探测所有启用端点的速度与连通性,并刷新端点选择排序。
# 注意:没有 ENABLE 开关,默认启用;可通过下列参数调优。
ENDPOINT_PROBE_INTERVAL_MS=10000
# Probes all enabled endpoints based on dynamic intervals and refreshes endpoint selection ranking.
# Note: No ENABLE switch, enabled by default; tune via parameters below.
#
# Dynamic Interval Rules (in priority order):
# 1. Timeout Override (10s): If endpoint's lastProbeErrorType === "timeout" and not recovered (lastProbeOk !== true)
# 2. Single-Vendor (10min): If vendor has only 1 enabled endpoint
# 3. Base Interval (default): All other endpoints
#
# ENDPOINT_PROBE_INTERVAL_MS controls the base interval. Single-vendor and timeout intervals are fixed.
ENDPOINT_PROBE_INTERVAL_MS=60000
ENDPOINT_PROBE_TIMEOUT_MS=5000
ENDPOINT_PROBE_CONCURRENCY=10
ENDPOINT_PROBE_CYCLE_JITTER_MS=1000
Expand Down
2 changes: 2 additions & 0 deletions messages/en/settings/providers/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
"probeOk": "OK",
"probeError": "Error",
"addEndpointDesc": "Add a new {providerType} endpoint for this vendor.",
"addEndpointDescGeneric": "Add a new API endpoint for this vendor.",
"columnType": "Type",
"endpointUrlLabel": "URL",
"endpointUrlPlaceholder": "https://api.example.com/v1",
"endpointLabelOptional": "Label (optional)",
Expand Down
2 changes: 2 additions & 0 deletions messages/ja/settings/providers/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
"probeOk": "OK",
"probeError": "エラー",
"addEndpointDesc": "このベンダーに {providerType} エンドポイントを追加します。",
"addEndpointDescGeneric": "このベンダーに新しい API エンドポイントを追加します。",
"columnType": "種類",
"endpointUrlLabel": "URL",
"endpointUrlPlaceholder": "https://api.example.com/v1",
"endpointLabelOptional": "ラベル (任意)",
Expand Down
2 changes: 2 additions & 0 deletions messages/ru/settings/providers/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
"probeOk": "OK",
"probeError": "Ошибка",
"addEndpointDesc": "Добавьте новый эндпоинт {providerType} для этого вендора.",
"addEndpointDescGeneric": "Добавьте новый API эндпоинт для этого вендора.",
"columnType": "Тип",
"endpointUrlLabel": "URL",
"endpointUrlPlaceholder": "https://api.example.com/v1",
"endpointLabelOptional": "Метка (необязательно)",
Expand Down
2 changes: 2 additions & 0 deletions messages/zh-CN/settings/providers/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
"probeOk": "正常",
"probeError": "异常",
"addEndpointDesc": "为该服务商添加一个新的 {providerType} 端点。",
"addEndpointDescGeneric": "为该服务商添加一个新的 API 端点。",
"columnType": "类型",
"endpointUrlLabel": "URL",
"endpointUrlPlaceholder": "https://api.example.com/v1",
"endpointLabelOptional": "标签(可选)",
Expand Down
2 changes: 2 additions & 0 deletions messages/zh-TW/settings/providers/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
"probeOk": "正常",
"probeError": "異常",
"addEndpointDesc": "為此供應商新增一個 {providerType} 端點。",
"addEndpointDescGeneric": "為此供應商新增一個新的 API 端點。",
"columnType": "類型",
"endpointUrlLabel": "URL",
"endpointUrlPlaceholder": "https://api.example.com/v1",
"endpointLabelOptional": "標籤(選填)",
Expand Down
25 changes: 25 additions & 0 deletions src/actions/provider-endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
deleteProviderVendor,
findProviderEndpointById,
findProviderEndpointProbeLogs,
findProviderEndpointsByVendor,
findProviderEndpointsByVendorAndType,
findProviderVendorById,
findProviderVendors,
Expand Down Expand Up @@ -185,6 +186,30 @@ export async function getProviderEndpoints(input: {
}
}

export async function getProviderEndpointsByVendor(input: {
vendorId: number;
}): Promise<ProviderEndpoint[]> {
try {
const session = await getAdminSession();
if (!session) {
return [];
}

const parsed = z.object({ vendorId: VendorIdSchema }).safeParse(input);
if (!parsed.success) {
logger.debug("getProviderEndpointsByVendor:invalid_input", {
error: parsed.error,
});
return [];
}

return await findProviderEndpointsByVendor(parsed.data.vendorId);
} catch (error) {
logger.error("getProviderEndpointsByVendor:error", error);
return [];
}
}

export async function addProviderEndpoint(
input: unknown
): Promise<ActionResult<{ endpoint: ProviderEndpoint }>> {
Expand Down
Loading
Loading