refactor: add WithServer dial option, remove (*Server).NewConfig#304
Merged
refactor: add WithServer dial option, remove (*Server).NewConfig#304
Conversation
Contributor
|
|
Overall Grade |
Security Reliability Complexity Hygiene |
Code Review Summary
| Analyzer | Status | Updated (UTC) | Details |
|---|---|---|---|
| Go | Mar 25, 2026 11:24a.m. | Review ↗ | |
| Shell | Mar 25, 2026 11:24a.m. | Review ↗ |
6ad96bb to
252d6b8
Compare
Exports gorums.WithServer(srv *Server) DialOption as the canonical way to wire a Server as the back-channel handler when creating a client Configuration. This replaces the internal withRequestHandler call that was previously hidden inside (*Server).NewConfig. (*Server).NewConfig is removed; callers that used it, e.g. system_test.go, are updated to use gorums.NewConfig with gorums.WithServer(srv). Closes #297. Related to #294.
7a8369c to
dfa23d4
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the public configuration-construction API by introducing WithServer(*Server) DialOption for wiring up a local server as the back-channel request handler during dialing, and removing the confusing (*Server).NewConfig method.
Changes:
- Add
WithServer(srv *Server) DialOptionas the exported way to install the back-channel request handler. - Remove
(*Server).NewConfigfrom the public API. - Update internal usage (system outbound config + tests) to use
gorums.NewConfig(..., gorums.WithServer(srv), ...).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| system_test.go | Updates back-channel test setup to use gorums.NewConfig(..., WithServer(...)) instead of srv.NewConfig. |
| system.go | Switches outbound config creation to prepend WithServer(s.srv) instead of the unexported withRequestHandler. |
| server.go | Removes the (*Server).NewConfig method. |
| opts.go | Introduces exported WithServer(*Server) DialOption wrapper around withRequestHandler. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This also panics if a nil server is passed.
This was referenced Mar 25, 2026
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
Introduces
WithServer(srv *Server) DialOptionas the public API for registering a local gorums server as the back-channel request handler when creating a configuration.This is used in peer-to-peer scenarios where a node acts as both server and client.
Removes the confusingly-named
(*Server).NewConfigmethod, which created aConfigurationfrom a server — the naming implied the wrong ownership direction.Changes
WithServer(srv *Server) DialOptiontoopts.go/config_opts.go(*Server).NewConfigfromserver.goWithServerRelated
Part of #294
Closes #297