Conversation
…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>
Contributor
There was a problem hiding this comment.
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
ExecutionTrackerSetterinterface incmd/server/main.go. - Replaces the
*module.QueryHandler/*module.CommandHandlertype switch with a singleExecutionTrackerSetterassertion inregisterPostStartServices.
Comments suppressed due to low confidence (1)
cmd/server/main.go:246
ExecutionTrackerSetteris exported while all other “minimal interfaces” in this section are unexported (e.g.,v1StoreIface,pipelineEventSetter,executionTrackerIface). Since this is only used internally incmd/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)
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ExecutionTrackerSetterinterface incmd/server/main.goalongside the other local server interfaces (pipelineEventSetter,executionTrackerIface, etc.)*module.QueryHandler/*module.CommandHandlerinregisterPostStartServiceswith a single interface assertionSetExecutionTracker(module.ExecutionTrackerProvider)methodMotivation
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 touchingcmd/server/main.go.Test plan
go build ./...passesgo test ./...passes (all packages green)golangci-lint run ./cmd/server/reports 0 issuescloses #62
🤖 Generated with Claude Code