Skip to content

refactor: replace concrete type switch with ExecutionTrackerSetter interface#119

Merged
intel352 merged 2 commits intomainfrom
refactor/issue-62-execution-tracker-setter-interface
Feb 23, 2026
Merged

refactor: replace concrete type switch with ExecutionTrackerSetter interface#119
intel352 merged 2 commits intomainfrom
refactor/issue-62-execution-tracker-setter-interface

Conversation

@intel352
Copy link
Contributor

Summary

  • Defines an ExecutionTrackerSetter interface in cmd/server/main.go alongside the other local server interfaces (pipelineEventSetter, executionTrackerIface, etc.)
  • Replaces the two-case type switch on *module.QueryHandler / *module.CommandHandler in registerPostStartServices with a single interface assertion
  • No behavior change — both concrete types already have a matching SetExecutionTracker(module.ExecutionTrackerProvider) method

Motivation

The old switch required editing the server file every time a new module type needed execution tracking. With the interface, any new module that implements SetExecutionTracker(module.ExecutionTrackerProvider) is automatically wired without touching cmd/server/main.go.

Test plan

  • go build ./... passes
  • go test ./... passes (all packages green)
  • golangci-lint run ./cmd/server/ reports 0 issues
  • Pre-push hooks passed

closes #62

🤖 Generated with Claude Code

…terface (#62)

Define an ExecutionTrackerSetter interface in cmd/server/main.go alongside
the other local server interfaces. The loop in registerPostStartServices now
uses a single interface assertion instead of a type switch on *module.QueryHandler
and *module.CommandHandler, so new module types that need execution tracking
only need to implement SetExecutionTracker — no server changes required.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 23, 2026 08:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the server’s post-start wiring to use an interface assertion instead of a concrete-type switch when injecting the execution tracker into CQRS handlers, reducing the need to update cmd/server/main.go as new handler types are added.

Changes:

  • Introduces an ExecutionTrackerSetter interface in cmd/server/main.go.
  • Replaces the *module.QueryHandler / *module.CommandHandler type switch with a single ExecutionTrackerSetter assertion in registerPostStartServices.
Comments suppressed due to low confidence (1)

cmd/server/main.go:246

  • ExecutionTrackerSetter is exported while all other “minimal interfaces” in this section are unexported (e.g., v1StoreIface, pipelineEventSetter, executionTrackerIface). Since this is only used internally in cmd/server/package main, consider making it unexported (e.g., executionTrackerSetter) to match the established naming convention and avoid implying a public API surface.
// ExecutionTrackerSetter is implemented by any module that accepts an
// ExecutionTrackerProvider. Using this interface in place of a concrete-type
// switch means the server does not need to be modified when new module types
// require execution tracking.
type ExecutionTrackerSetter interface {
	SetExecutionTracker(module.ExecutionTrackerProvider)
}

@intel352 intel352 merged commit ea2ed49 into main Feb 23, 2026
14 checks passed
@intel352 intel352 deleted the refactor/issue-62-execution-tracker-setter-interface branch February 23, 2026 09:20
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.

Replace concrete module type switch with ExecutionTrackerSetter interface in cmd/server/main.go

2 participants