Skip to content

Fx module wiring and lifecycle cleanup#129

Closed
yushan8 wants to merge 5 commits into
mainfrom
fx-cleanups
Closed

Fx module wiring and lifecycle cleanup#129
yushan8 wants to merge 5 commits into
mainfrom
fx-cleanups

Conversation

@yushan8

@yushan8 yushan8 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Extract comparison logic into controller/comparer.go

Graph comparison logic moved out of getchangedtargets.go into a targetGraphComparer type. The controller calls newTargetGraphComparer(...).Compare(...) directly — no wrapper method.

Move per-request init to construction time in nativeOrchestrator

  • Config parsing — config.Parse() was called every request. Params.ConfigFilePath replaced with Params.Config config.RepositoryConfigProvider, injected once.
  • gitFactory nil fallback — moved to the constructor.
  • graphRunner nil-check + inline bazel/runner creation — replaced with a GraphRunnerFactory func set at construction. defaultGraphRunnerFactory provides the bazel-backed implementation; tests inject their own.
  • Metrics scope and counters — scope.SubScope("get_target_graph") and its counters are pre-created as struct fields instead of allocated per request.
  • GetTargetGraph decomposed into prepareWorkspace (lease → checkout → apply → cleanup) and computeGraph (cache check → compute → store). The method itself is now metrics + prepare + compute.

Remove dead appCtx from orchestrator and repomanager

Both stored an application-lifetime context but never read it. Removed. Only the controller retains appCtx — it's actually used for linkRequestCtx and fire-and-forget cache writes.

Make all Params structs Fx-injectable

  • controller.Params, orchestrator.Params, repomanager.Params all carry fx.In.
  • Constructor signatures simplified from New(appCtx, Params) to New(Params).

Add module/module.go

fx.Module("tango") wires repomanager → orchestrator → controller. Documents what callers must supply.

Convert example/main.go to Fx

Uses fx.New(...).Run() with fx.Lifecycle hooks for dispatcher start/stop, temp directory cleanup, and signal-based shutdown.

@yushan8 yushan8 marked this pull request as ready for review June 30, 2026 20:01
@yushan8 yushan8 requested review from a team as code owners June 30, 2026 20:01
@yushan8 yushan8 marked this pull request as draft June 30, 2026 20:08
@yushan8 yushan8 closed this Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant