chore(token-refresh): 添加 Antigravity Token 刷新调试日志
- NeedsRefresh 判断为 true 时输出 expires_at、time_until_expiry、window - 修正注释中的刷新窗口描述(10分钟 → 15分钟)
This commit is contained in:
@@ -2,6 +2,7 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,7 +29,7 @@ func (r *AntigravityTokenRefresher) CanRefresh(account *Account) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NeedsRefresh 检查账户是否需要刷新
|
// NeedsRefresh 检查账户是否需要刷新
|
||||||
// Antigravity 使用固定的10分钟刷新窗口,忽略全局配置
|
// Antigravity 使用固定的15分钟刷新窗口,忽略全局配置
|
||||||
func (r *AntigravityTokenRefresher) NeedsRefresh(account *Account, _ time.Duration) bool {
|
func (r *AntigravityTokenRefresher) NeedsRefresh(account *Account, _ time.Duration) bool {
|
||||||
if !r.CanRefresh(account) {
|
if !r.CanRefresh(account) {
|
||||||
return false
|
return false
|
||||||
@@ -37,7 +38,13 @@ func (r *AntigravityTokenRefresher) NeedsRefresh(account *Account, _ time.Durati
|
|||||||
if expiresAt == nil {
|
if expiresAt == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return time.Until(*expiresAt) < antigravityRefreshWindow
|
timeUntilExpiry := time.Until(*expiresAt)
|
||||||
|
needsRefresh := timeUntilExpiry < antigravityRefreshWindow
|
||||||
|
if needsRefresh {
|
||||||
|
fmt.Printf("[AntigravityTokenRefresher] Account %d needs refresh: expires_at=%s, time_until_expiry=%v, window=%v\n",
|
||||||
|
account.ID, expiresAt.Format("2006-01-02 15:04:05"), timeUntilExpiry, antigravityRefreshWindow)
|
||||||
|
}
|
||||||
|
return needsRefresh
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh 执行 token 刷新
|
// Refresh 执行 token 刷新
|
||||||
|
|||||||
Reference in New Issue
Block a user