(channel *Channel, usingKey string, status int)
| 523 | } |
| 524 | |
| 525 | func 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 | |
| 555 | func UpdateChannelStatus(channelId int, usingKey string, status int, reason string) bool { |
| 556 | if common.MemoryCacheEnabled { |
no test coverage detected