fix; channel testing

This commit is contained in:
ckt 2023-10-22 10:46:54 +00:00 committed by GitHub
parent 765e5f8b66
commit d79a7b5902
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -253,7 +253,7 @@ func testAllChannels(notify bool) error {
} }
go func() { go func() {
for _, channel := range channels { for _, channel := range channels {
if channel.Status != common.ChannelStatusEnabled || (channel.Status == common.ChannelStatusAutoDisabled && common.AutoReEnableFailedChannelEnabled) { if channel.Status == common.ChannelStatusManuallyDisabled || channel.Status == common.ChannelStatusUnknown {
continue continue
} }
tik := time.Now() tik := time.Now()
@ -264,11 +264,9 @@ func testAllChannels(notify bool) error {
if milliseconds > disableThreshold { if milliseconds > disableThreshold {
err = errors.New(fmt.Sprintf("响应时间 %.2fs 超过阈值 %.2fs", float64(milliseconds)/1000.0, float64(disableThreshold)/1000.0)) err = errors.New(fmt.Sprintf("响应时间 %.2fs 超过阈值 %.2fs", float64(milliseconds)/1000.0, float64(disableThreshold)/1000.0))
disableChannel(channel.Id, channel.Name, err.Error()) disableChannel(channel.Id, channel.Name, err.Error())
} } else if shouldDisableChannel(openaiErr, -1) {
if shouldDisableChannel(openaiErr, -1) {
disableChannel(channel.Id, channel.Name, err.Error()) disableChannel(channel.Id, channel.Name, err.Error())
} } else if channel.Status == common.ChannelStatusAutoDisabled && common.AutoReEnableFailedChannelEnabled {
if channel.Status == common.ChannelStatusAutoDisabled && common.AutoReEnableFailedChannelEnabled {
enableChannel(channel.Id, channel.Name) enableChannel(channel.Id, channel.Name)
} }
channel.UpdateResponseTime(milliseconds) channel.UpdateResponseTime(milliseconds)