feat: add priority demotion controls
This commit is contained in:
@@ -50,7 +50,6 @@ type RunnerPolicyForm = {
|
||||
hardStopStatusCodes: string[];
|
||||
hardStopKeywords: string[];
|
||||
priorityDemoteEnabled: boolean;
|
||||
priorityDemoteStep: string;
|
||||
priorityDemoteCategories: string[];
|
||||
priorityDemoteCodes: string[];
|
||||
priorityDemoteStatusCodes: string[];
|
||||
@@ -406,11 +405,7 @@ function RunnerPolicyEditor(props: {
|
||||
{activeStrategy === 'priorityDemote' && (
|
||||
<div className="runtimePolicyRows runnerPolicyDetailRows">
|
||||
<Toggle checked={props.form.priorityDemoteEnabled} label="启用优先级降级" onChange={(checked) => patch({ priorityDemoteEnabled: checked })} />
|
||||
<Label>
|
||||
降级步长
|
||||
<Input value={props.form.priorityDemoteStep} inputMode="numeric" onChange={(event) => patch({ priorityDemoteStep: event.target.value })} />
|
||||
<span className="runtimeFieldHint">命中降级规则后,失败平台动态优先级向后调整的幅度,默认 100。</span>
|
||||
</Label>
|
||||
<span className="runtimeFieldHint spanTwo">命中降级规则后,失败平台会自动调整到当前所有平台的优先级队尾。</span>
|
||||
<KeywordField label="降级分类" value={props.form.priorityDemoteCategories} onChange={(value) => patch({ priorityDemoteCategories: value })} />
|
||||
<KeywordField label="降级错误码" value={props.form.priorityDemoteCodes} onChange={(value) => patch({ priorityDemoteCodes: value })} />
|
||||
<KeywordField label="降级状态码" value={props.form.priorityDemoteStatusCodes} onChange={(value) => patch({ priorityDemoteStatusCodes: value })} />
|
||||
@@ -478,7 +473,6 @@ function runnerPolicyToForm(policy: GatewayRunnerPolicy | null): RunnerPolicyFor
|
||||
hardStopStatusCodes: tagsFromValue(hardStop.statusCodes ?? []),
|
||||
hardStopKeywords: tagsFromValue(hardStop.keywords ?? ['invalid_parameter', 'missing required', 'bad request', 'insufficient balance']),
|
||||
priorityDemoteEnabled: readBool(priorityDemote.enabled, true),
|
||||
priorityDemoteStep: String(readNumber(priorityDemote.demoteStep, 100)),
|
||||
priorityDemoteCategories: tagsFromValue(priorityDemote.categories ?? ['network', 'timeout', 'stream_error', 'rate_limit', 'provider_5xx', 'provider_overloaded']),
|
||||
priorityDemoteCodes: tagsFromValue(priorityDemote.codes ?? ['network', 'timeout', 'stream_read_error', 'rate_limit', 'server_error', 'overloaded']),
|
||||
priorityDemoteStatusCodes: tagsFromValue(priorityDemote.statusCodes ?? [408, 429, 500, 502, 503, 504]),
|
||||
@@ -516,7 +510,6 @@ function runnerFormToPayload(form: RunnerPolicyForm): GatewayRunnerPolicyUpsertR
|
||||
},
|
||||
priorityDemotePolicy: {
|
||||
enabled: form.priorityDemoteEnabled,
|
||||
demoteStep: positiveInt(form.priorityDemoteStep, 100),
|
||||
categories: cleanTags(form.priorityDemoteCategories),
|
||||
codes: cleanTags(form.priorityDemoteCodes),
|
||||
statusCodes: parseNumberTags(form.priorityDemoteStatusCodes),
|
||||
|
||||
Reference in New Issue
Block a user