feat: 支持配置渠道被禁用后是否清空渠道粘性 (#5306)
* fix: evict stale channel affinity * feat: configure disabled channel affinity retention --------- Co-authored-by: Seefs <i@seefs.me>
This commit is contained in:
@@ -100,6 +100,9 @@ export function ChannelAffinitySection(props: Props) {
|
||||
const [switchOnSuccess, setSwitchOnSuccess] = useState(
|
||||
props.defaultValues['channel_affinity_setting.switch_on_success']
|
||||
)
|
||||
const [keepOnChannelDisabled, setKeepOnChannelDisabled] = useState(
|
||||
props.defaultValues['channel_affinity_setting.keep_on_channel_disabled']
|
||||
)
|
||||
const [maxEntries, setMaxEntries] = useState(
|
||||
props.defaultValues['channel_affinity_setting.max_entries']
|
||||
)
|
||||
@@ -136,6 +139,9 @@ export function ChannelAffinitySection(props: Props) {
|
||||
setSwitchOnSuccess(
|
||||
props.defaultValues['channel_affinity_setting.switch_on_success']
|
||||
)
|
||||
setKeepOnChannelDisabled(
|
||||
props.defaultValues['channel_affinity_setting.keep_on_channel_disabled']
|
||||
)
|
||||
setMaxEntries(props.defaultValues['channel_affinity_setting.max_entries'])
|
||||
setDefaultTtl(
|
||||
props.defaultValues['channel_affinity_setting.default_ttl_seconds']
|
||||
@@ -231,6 +237,14 @@ export function ChannelAffinitySection(props: Props) {
|
||||
key: 'channel_affinity_setting.switch_on_success',
|
||||
value: String(switchOnSuccess),
|
||||
})
|
||||
if (
|
||||
keepOnChannelDisabled !==
|
||||
props.defaultValues['channel_affinity_setting.keep_on_channel_disabled']
|
||||
)
|
||||
updates.push({
|
||||
key: 'channel_affinity_setting.keep_on_channel_disabled',
|
||||
value: String(keepOnChannelDisabled),
|
||||
})
|
||||
if (
|
||||
maxEntries !==
|
||||
props.defaultValues['channel_affinity_setting.max_entries']
|
||||
@@ -397,6 +411,14 @@ export function ChannelAffinitySection(props: Props) {
|
||||
'If the affinity channel fails and retry succeeds on another channel, update affinity to the successful channel.'
|
||||
)}
|
||||
/>
|
||||
<SettingsSwitchField
|
||||
checked={keepOnChannelDisabled}
|
||||
onCheckedChange={setKeepOnChannelDisabled}
|
||||
label={t('Keep affinity when channel is disabled')}
|
||||
description={t(
|
||||
'When enabled, keep the affinity entry even if the affinity channel is disabled or no longer usable for the current group/model. Leave it off to delete the entry and select another channel.'
|
||||
)}
|
||||
/>
|
||||
|
||||
<Separator />
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ export interface CacheStats {
|
||||
export interface ChannelAffinitySettings {
|
||||
'channel_affinity_setting.enabled': boolean
|
||||
'channel_affinity_setting.switch_on_success': boolean
|
||||
'channel_affinity_setting.keep_on_channel_disabled': boolean
|
||||
'channel_affinity_setting.max_entries': number
|
||||
'channel_affinity_setting.default_ttl_seconds': number
|
||||
'channel_affinity_setting.rules': string
|
||||
|
||||
Reference in New Issue
Block a user