feat(channels): add auto-disable-only channel test mode (#6728)

This commit is contained in:
Seefs
2026-08-10 12:47:44 +08:00
committed by GitHub
parent 823e26304a
commit 5d3423bec1
13 changed files with 146 additions and 11 deletions
@@ -63,7 +63,11 @@ const numericString = z.string().refine((value) => {
return !Number.isNaN(Number(trimmed)) && Number(trimmed) >= 0
}, 'Enter a non-negative number or leave empty')
const channelTestModes = ['scheduled_all', 'passive_recovery'] as const
const channelTestModes = [
'scheduled_all',
'auto_ban_only',
'passive_recovery',
] as const
type ChannelTestMode = (typeof channelTestModes)[number]
const routingReliabilitySchema = z
@@ -148,7 +152,10 @@ type NormalizedRoutingReliabilityValues = {
}
function normalizeChannelTestMode(value?: string): ChannelTestMode {
return value === 'passive_recovery' ? 'passive_recovery' : 'scheduled_all'
if (value === 'auto_ban_only' || value === 'passive_recovery') {
return value
}
return 'scheduled_all'
}
const buildFormDefaults = (
@@ -250,6 +257,23 @@ export function RoutingReliabilitySection({
const autoDisableStatusCodes = form.watch('AutomaticDisableStatusCodes')
const autoRetryStatusCodes = form.watch('AutomaticRetryStatusCodes')
const channelTestMode = form.watch('monitor_setting.channel_test_mode')
let channelTestModeDescription: string
switch (channelTestMode) {
case 'auto_ban_only':
channelTestModeDescription = t(
'Periodically checks only channels with auto-disable enabled, excluding manually disabled channels.'
)
break
case 'passive_recovery':
channelTestModeDescription = t(
'Does not check healthy channels. It only rechecks auto-disabled channels and restores them after they recover.'
)
break
default:
channelTestModeDescription = t(
'Periodically checks all channels except manually disabled ones to detect failures and recover channels automatically.'
)
}
const autoDisableParsed = useMemo(
() => parseHttpStatusCodeRules(autoDisableStatusCodes),
[autoDisableStatusCodes]
@@ -391,11 +415,17 @@ export function RoutingReliabilitySection({
items={[
{
value: 'scheduled_all',
label: t('Scheduled full test'),
label: t('Actively check all channels'),
},
{
value: 'auto_ban_only',
label: t(
'Actively check auto-disable-enabled channels'
),
},
{
value: 'passive_recovery',
label: t('Passive recovery only'),
label: t('Check channels awaiting recovery only'),
},
]}
value={field.value}
@@ -409,18 +439,19 @@ export function RoutingReliabilitySection({
<SelectContent alignItemWithTrigger={false}>
<SelectGroup>
<SelectItem value='scheduled_all'>
{t('Scheduled full test')}
{t('Actively check all channels')}
</SelectItem>
<SelectItem value='auto_ban_only'>
{t('Actively check auto-disable-enabled channels')}
</SelectItem>
<SelectItem value='passive_recovery'>
{t('Passive recovery only')}
{t('Check channels awaiting recovery only')}
</SelectItem>
</SelectGroup>
</SelectContent>
</Select>
<FormDescription>
{t(
'Scheduled full test probes non-manually-disabled channels; passive recovery only checks auto-disabled channels after real request failures.'
)}
{channelTestModeDescription}
</FormDescription>
<FormMessage />
</FormItem>
+4 -1
View File
@@ -235,7 +235,10 @@ export type ModelSettings = {
AutomaticRetryStatusCodes: string
'monitor_setting.auto_test_channel_enabled': boolean
'monitor_setting.auto_test_channel_minutes': number
'monitor_setting.channel_test_mode': 'scheduled_all' | 'passive_recovery'
'monitor_setting.channel_test_mode':
| 'scheduled_all'
| 'auto_ban_only'
| 'passive_recovery'
'channel_affinity_setting.enabled': boolean
'channel_affinity_setting.switch_on_success': boolean
'channel_affinity_setting.keep_on_channel_disabled': boolean