Skip to content

enhancement: Eliminate redundant OAuth client creation in initDocsAndGemini #31

Description

@jflowers

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):

  1. Line 190: initServices() creates OAuth client + HTTP client + Drive/Calendar services
  2. Line 251: initDocsAndGemini() creates another OAuth client + HTTP client for Docs/Gemini
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions