MCPcopy Create free account
hub / github.com/Rfym21/Qwen2API / verifyRedisCommandChannel

Function verifyRedisCommandChannel

src/utils/redis.js:79–107  ·  view source on GitHub ↗
(client)

Source from the content-addressed store, hash-verified

77 */
78const verifyRedisCommandChannel = async (client) => {
79 let lastError = null
80
81 for (let attempt = 1; attempt <= REDIS_VERIFY_RETRIES; attempt++) {
82 try {
83 const pong = await client.ping()
84 if (pong !== 'PONG') {
85 throw new Error(`PING 返回异常: ${pong}`)
86 }
87
88 if (attempt > 1) {
89 logger.info(`Redis命令通道在第 ${attempt} 次校验时恢复正常`, 'REDIS', '✅')
90 }
91
92 return
93 } catch (error) {
94 lastError = error
95
96 if (attempt >= REDIS_VERIFY_RETRIES) {
97 break
98 }
99
100 logger.warn(`Redis命令通道校验失败,第 ${attempt} 次后准备重试: ${error.message}`, 'REDIS')
101 await new Promise(resolve => setTimeout(resolve, REDIS_VERIFY_RETRY_DELAY))
102 }
103 }
104
105 throw new Error(`Redis命令通道不可用: ${lastError ? lastError.message : '未知错误'}`)
106}
107
108/**
109 * 清理空闲定时器
110 */

Callers 1

connectRedisFunction · 0.85

Calls 2

infoMethod · 0.80
warnMethod · 0.80

Tested by

no test coverage detected