MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / handlerMultiKeyUpdate

Function handlerMultiKeyUpdate

model/channel.go:525–553  ·  view source on GitHub ↗
(channel *Channel, usingKey string, status int)

Source from the content-addressed store, hash-verified

523}
524
525func handlerMultiKeyUpdate(channel *Channel, usingKey string, status int) {
526 keys := channel.getKeys()
527 if len(keys) == 0 {
528 channel.Status = status
529 } else {
530 var keyIndex int
531 for i, key := range keys {
532 if key == usingKey {
533 keyIndex = i
534 break
535 }
536 }
537 if channel.ChannelInfo.MultiKeyStatusList == nil {
538 channel.ChannelInfo.MultiKeyStatusList = make(map[int]int)
539 }
540 if status == common.ChannelStatusEnabled {
541 delete(channel.ChannelInfo.MultiKeyStatusList, keyIndex)
542 } else {
543 channel.ChannelInfo.MultiKeyStatusList[keyIndex] = status
544 }
545 if len(channel.ChannelInfo.MultiKeyStatusList) >= channel.ChannelInfo.MultiKeySize {
546 channel.Status = common.ChannelStatusAutoDisabled
547 info := channel.GetOtherInfo()
548 info["status_reason"] = "All keys are disabled"
549 info["status_time"] = common.GetTimestamp()
550 channel.SetOtherInfo(info)
551 }
552 }
553}
554
555func UpdateChannelStatus(channelId int, usingKey string, status int, reason string) bool {
556 if common.MemoryCacheEnabled {

Callers 1

UpdateChannelStatusFunction · 0.85

Calls 4

GetTimestampFunction · 0.92
getKeysMethod · 0.80
GetOtherInfoMethod · 0.80
SetOtherInfoMethod · 0.80

Tested by

no test coverage detected