Przeglądaj źródła

fix: ensure ChannelIsMultiKey context key is set to false for single key retries

CaIon 7 miesięcy temu
rodzic
commit
e2429f20f8
1 zmienionych plików z 3 dodań i 0 usunięć
  1. 3 0
      middleware/distributor.go

+ 3 - 0
middleware/distributor.go

@@ -269,6 +269,9 @@ func SetupContextForSelectedChannel(c *gin.Context, channel *model.Channel, mode
 	if channel.ChannelInfo.IsMultiKey {
 		common.SetContextKey(c, constant.ContextKeyChannelIsMultiKey, true)
 		common.SetContextKey(c, constant.ContextKeyChannelMultiKeyIndex, index)
+	} else {
+		// 必须设置为 false,否则在重试到单个 key 的时候会导致日志显示错误
+		common.SetContextKey(c, constant.ContextKeyChannelIsMultiKey, false)
 	}
 	// c.Request.Header.Set("Authorization", fmt.Sprintf("Bearer %s", key))
 	common.SetContextKey(c, constant.ContextKeyChannelKey, key)