refactor(githubevents): generic dispatch helper - #281
Merged
Conversation
4 tasks
replace exec-based gofmt call in gen/format.go with go/format, so the generator formats in-process instead of shelling out. make format and make generate now run gofumpt -extra over gen and githubevents, matching what golangci-lint expects. repo was already gofumpt v0.7.0 clean, so no output diff.
cbrgm
force-pushed
the
phase-2-modern-go
branch
from
August 12, 2026 12:49
2c3a05e to
b40c7ea
Compare
cbrgm
force-pushed
the
phase-3-generic-dispatch
branch
from
August 12, 2026 12:51
6aa9a45 to
8c76fbe
Compare
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.
What
Collapse the ~500 copy-pasted concurrency loops into one hand-written generic helper.
githubevents/dispatch.gowithdispatch[T], the single implementation of the errgroup + panic-recovery + first-error-wins loophandle*methods now calldispatch(...)instead of repeating ~27 lines eachgithubevents/dispatch_test.go) lock the behavior through the public API before the refactorNet: +722 / -5579 lines. Stacked on #280.
Why
The same errgroup/recover block was generated hundreds of times. One generic helper is far easier to reason about and test, and it only touches unexported internals so the public API is unchanged.
Behavior is preserved exactly, and i was deliberate about it: same errgroup first-error-wins semantics (not
errors.Join, so if two callbacks fail only the first surfaces, like before), the exact"recovered from panic: %v"message, and all the guard / wrong-action errors verbatim. The characterization tests (panic recovery, fan-out count, error propagation, empty-action rejection, the Any path) were written to pass on the old code first, then kept passing after the refactor.Testing
go test ./githubevents/ -run TestDispatch -v-> 5/5, unchanged before and after the refactormake testgreen (incl. the 100+ generated per-event test files),make apidiff-> API compatiblegrep -rl errgroup githubevents/-> onlydispatch.go+events.go(the bespokehandleError), noevents_*.goChecklist
dispatch_test.gocharacterization suite)