Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
71c28e43
Commit
71c28e43
authored
Dec 25, 2025
by
ianshaw
Browse files
feat(service): 定义 Gemini 服务端口接口
- 定义 OAuth 服务接口 - 定义 Token 缓存服务接口 - 定义 Code Assist 服务接口
parent
2bafc28a
Changes
3
Show whitespace changes
Inline
Side-by-side
backend/internal/service/gemini_oauth.go
0 → 100644
View file @
71c28e43
package
ports
import
(
"context"
"github.com/Wei-Shaw/sub2api/internal/pkg/geminicli"
)
// GeminiOAuthClient performs Google OAuth token exchange/refresh for Gemini integration.
type
GeminiOAuthClient
interface
{
ExchangeCode
(
ctx
context
.
Context
,
code
,
codeVerifier
,
redirectURI
,
proxyURL
string
)
(
*
geminicli
.
TokenResponse
,
error
)
RefreshToken
(
ctx
context
.
Context
,
refreshToken
,
proxyURL
string
)
(
*
geminicli
.
TokenResponse
,
error
)
}
backend/internal/service/gemini_token_cache.go
0 → 100644
View file @
71c28e43
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
}
backend/internal/service/geminicli_codeassist.go
0 → 100644
View file @
71c28e43
package
ports
import
(
"context"
"github.com/Wei-Shaw/sub2api/internal/pkg/geminicli"
)
// GeminiCliCodeAssistClient calls GeminiCli internal Code Assist endpoints.
type
GeminiCliCodeAssistClient
interface
{
LoadCodeAssist
(
ctx
context
.
Context
,
accessToken
,
proxyURL
string
,
req
*
geminicli
.
LoadCodeAssistRequest
)
(
*
geminicli
.
LoadCodeAssistResponse
,
error
)
OnboardUser
(
ctx
context
.
Context
,
accessToken
,
proxyURL
string
,
req
*
geminicli
.
OnboardUserRequest
)
(
*
geminicli
.
OnboardUserResponse
,
error
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment