refactor: remove PipelineHandler getter from pipelinesteps plugin#118
Merged
refactor: remove PipelineHandler getter from pipelinesteps plugin#118
Conversation
Move handler wiring from cmd/server/main.go into the plugin's own lifecycle via optional setter interfaces and a wiring hook: - Plugin implements SetStepRegistry() and SetLogger() — engine's LoadPlugin() detects and calls these after registering factories - Plugin adds a WiringHook that injects dependencies into the PipelineWorkflowHandler and registers it as a named service - cmd/server/main.go no longer reaches inside the plugin — it discovers the handler via service registry lookup when needed (e.g., to wire SetEventRecorder post-start) Closes #60 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The plugin now configures itself internally via optional-interface injection and a WiringHook rather than exposing a concrete handler reference to callers. - engine.LoadPlugin() detects SetStepRegistry/SetLogger optional interfaces and injects the engine's step registry and slog.Logger into plugins after workflow handlers are registered - Plugin.WiringHooks() wires those injected dependencies into the handler and registers it under PipelineHandlerServiceName in the app service registry - cmd/server/main.go no longer retains a pipelinePlugin variable; EventRecorder wiring in registerPostStartServices looks up the handler via the service registry - engine_pipeline_test.go finds the handler via type assertion instead of getter - Removed pipelineEventSetter interface and pipelineHandler serviceComponents field Closes #60 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the pipelinesteps plugin integration so callers no longer access a concrete handler via a plugin-specific getter, and instead rely on engine-driven optional interface injection and service registry discovery.
Changes:
- Removed
PipelineHandler()getter fromplugins/pipelinestepsand added optionalSetStepRegistry()/SetLogger()setters plus a wiring hook that registers the handler as a named service. - Extended
StdEngine.LoadPlugin()to inject step registry and (optionally) a*slog.Loggerinto plugins that implement the new setter interfaces. - Updated server wiring and tests to discover the pipeline handler via the service registry rather than via direct plugin access.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| plugins/pipelinesteps/plugin.go | Removes handler getter; adds optional setters + wiring hook; registers handler under a constant service name |
| engine.go | Adds optional-interface injection for step registry and *slog.Logger during plugin load |
| cmd/server/main.go | Removes direct plugin handler wiring; wires EventRecorder via service-registry lookup post-start |
| engine_pipeline_test.go | Updates tests to locate the pipeline handler from the engine’s handler list |
| cmd/server/main_test.go | Adjusts tests for updated buildEngine signature |
| plugins/http/plugin_test.go | Formatting-only change |
Comments suppressed due to low confidence (2)
plugins/pipelinesteps/plugin.go:145
app.RegisterServiceerrors are currently ignored. If registration fails (e.g., name collision), the PipelineWorkflowHandler won’t be discoverable via the service registry and post-start wiring (SetEventRecorder) will silently not happen. Return the error (or at least log it) so mis-wiring fails fast and is diagnosable.
// Register the handler as a service so callers can discover it
// (e.g. to wire SetEventRecorder post-start) without a plugin-specific getter.
_ = app.RegisterService(PipelineHandlerServiceName, p.pipelineHandler)
return nil
cmd/server/main.go:871
- If the pipeline handler service is missing from the registry or doesn’t implement
SetEventRecorder, this branch becomes a silent no-op and pipeline execution events won’t be recorded without any signal. Consider adding a Debug/Warn log when the service isn’t found and when the type assertion fails, to make misconfiguration visible in production.
if svc, ok := engine.GetApp().SvcRegistry()[pluginpipeline.PipelineHandlerServiceName]; ok {
if ph, ok := svc.(eventRecorderSetter); ok {
recorder := evstore.NewEventRecorderAdapter(app.stores.eventStore)
ph.SetEventRecorder(recorder)
logger.Info("Wired EventRecorder to PipelineWorkflowHandler")
}
}
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 6 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
plugins/pipelinesteps/plugin.go:145
app.RegisterServicereturns an error (e.g., duplicate service name). Ignoring it here can silently break post-start wiring that relies on this service being present. Consider handling the error and returning it from the wiring hook (or at least logging it) so BuildFromConfig fails fast if the handler service cannot be registered.
// Register the handler as a service so callers can discover it
// (e.g. to wire SetEventRecorder post-start) without a plugin-specific getter.
_ = app.RegisterService(PipelineHandlerServiceName, p.pipelineHandler)
return nil
The handlers package import was left behind after PR changes removed all usage of the package from cmd/server/main.go, causing build and lint failures. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
PipelineHandler()getter fromplugins/pipelinesteps/plugin.go— callers no longer reach inside the plugin to configure itSetStepRegistry()andSetLogger()optional interfaces, which the engine'sLoadPlugin()detects and calls automaticallyWiringHookthat injects dependencies into the handler and registers it as a named service (pipeline-workflow-handler)cmd/server/main.godiscovers the handler via service registry lookup when needed (e.g., for wiringSetEventRecorderpost-start)LoadPlugin()now supportsstepRegistrySetterandslogLoggerSetteroptional interfaces for all pluginsCloses #60
Test plan
go build ./...passesgo test ./...— all tests passgolangci-lint run— 0 issues (verified by pre-push hook)🤖 Generated with Claude Code