Skip to content

refactor: add WithServer dial option, remove (*Server).NewConfig#304

Merged
meling merged 2 commits intomasterfrom
feature/297/with-server-remove-server-newconfig
Mar 25, 2026
Merged

refactor: add WithServer dial option, remove (*Server).NewConfig#304
meling merged 2 commits intomasterfrom
feature/297/with-server-remove-server-newconfig

Conversation

@meling
Copy link
Member

@meling meling commented Mar 25, 2026

Summary

Introduces WithServer(srv *Server) DialOption as 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).NewConfig method, which created a Configuration from a server — the naming implied the wrong ownership direction.

Changes

  • Add WithServer(srv *Server) DialOption to opts.go / config_opts.go
  • Remove (*Server).NewConfig from server.go
  • Update internal callers to use WithServer

Related

Part of #294
Closes #297

@deepsource-io
Copy link
Contributor

deepsource-io bot commented Mar 25, 2026

DeepSource Code Review

We reviewed changes in 9395ae5...8fb7c70 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

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 ↗

@meling meling force-pushed the feature/296/unexport-manager branch 2 times, most recently from 6ad96bb to 252d6b8 Compare March 25, 2026 11:05
Base automatically changed from feature/296/unexport-manager to master March 25, 2026 11:07
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.
@meling meling force-pushed the feature/297/with-server-remove-server-newconfig branch from 7a8369c to dfa23d4 Compare March 25, 2026 11:09
@meling meling requested a review from Copilot March 25, 2026 11:10
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

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) DialOption as the exported way to install the back-channel request handler.
  • Remove (*Server).NewConfig from 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.
@meling meling merged commit 5a184a6 into master Mar 25, 2026
5 checks passed
@meling meling deleted the feature/297/with-server-remove-server-newconfig branch March 25, 2026 11:26
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.

feat: export WithServer dial option; remove Server.NewConfig

2 participants