Summary
initDocsAndGemini in cmd/gcal-organizer/assign_tasks.go:112 creates a new OAuth client and HTTP client every time it is called, even though initServices already created one in the same command execution.
Current Flow
In runCmd.RunE (main.go):
- Line 190:
initServices() creates OAuth client + HTTP client + Drive/Calendar services
- Line 251:
initDocsAndGemini() creates another OAuth client + HTTP client for Docs/Gemini
- Line 311:
initDocsOnly() creates yet another OAuth client + HTTP client for Docs
Each call to initDocsAndGemini / initDocsOnly triggers a fresh token refresh cycle and OAuth client instantiation.
Fix
Refactor to pass the existing *http.Client from initServices to initDocsAndGemini and initDocsOnly:
func initDocsAndGemini(ctx context.Context, cfg *config.Config, store secrets.SecretStore, httpClient *http.Client) (...)
This avoids redundant token refreshes and unnecessary OAuth client construction.
Priority
MEDIUM — Performance improvement and cleaner resource management.
Summary
initDocsAndGeminiincmd/gcal-organizer/assign_tasks.go:112creates a new OAuth client and HTTP client every time it is called, even thoughinitServicesalready created one in the same command execution.Current Flow
In
runCmd.RunE(main.go):initServices()creates OAuth client + HTTP client + Drive/Calendar servicesinitDocsAndGemini()creates another OAuth client + HTTP client for Docs/GeminiinitDocsOnly()creates yet another OAuth client + HTTP client for DocsEach call to
initDocsAndGemini/initDocsOnlytriggers a fresh token refresh cycle and OAuth client instantiation.Fix
Refactor to pass the existing
*http.ClientfrominitServicestoinitDocsAndGeminiandinitDocsOnly:This avoids redundant token refreshes and unnecessary OAuth client construction.
Priority
MEDIUM — Performance improvement and cleaner resource management.