feat: enhanced channel test

This commit is contained in:
ckt1031 2023-10-25 20:06:12 +08:00
parent 624c887366
commit 8b4d2773d2

View File

@ -261,12 +261,17 @@ func testAllChannels(notify bool) error {
err, openaiErr := testChannel(channel, *testRequest)
tok := time.Now()
milliseconds := tok.Sub(tik).Milliseconds()
channelBeninDisabled := false
if milliseconds > disableThreshold {
err = errors.New(fmt.Sprintf("响应时间 %.2fs 超过阈值 %.2fs", float64(milliseconds)/1000.0, float64(disableThreshold)/1000.0))
disableChannel(channel.Id, channel.Name, err.Error())
} else if shouldDisableChannel(openaiErr, -1) {
channelBeninDisabled = true
}
if shouldDisableChannel(openaiErr, -1) {
disableChannel(channel.Id, channel.Name, err.Error())
} else if channel.Status == common.ChannelStatusAutoDisabled && common.AutoReEnableFailedChannelEnabled {
channelBeninDisabled = true
}
if channel.Status == common.ChannelStatusAutoDisabled && common.AutoReEnableFailedChannelEnabled && !channelBeninDisabled {
enableChannel(channel.Id, channel.Name)
}
channel.UpdateResponseTime(milliseconds)