feat(service): 定义 Gemini 服务端口接口

- 定义 OAuth 服务接口
- 定义 Token 缓存服务接口
- 定义 Code Assist 服务接口
This commit is contained in:
ianshaw
2025-12-25 06:43:57 -08:00
parent 2bafc28a9b
commit 71c28e436a
3 changed files with 42 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
package ports
import (
"context"
"time"
)
// GeminiTokenCache stores short-lived access tokens and coordinates refresh to avoid stampedes.
type GeminiTokenCache interface {
// cacheKey should be stable for the token scope; for GeminiCli OAuth we primarily use project_id.
GetAccessToken(ctx context.Context, cacheKey string) (string, error)
SetAccessToken(ctx context.Context, cacheKey string, token string, ttl time.Duration) error
AcquireRefreshLock(ctx context.Context, cacheKey string, ttl time.Duration) (bool, error)
ReleaseRefreshLock(ctx context.Context, cacheKey string) error
}