Skip to content

refactor: update all callers to use new NewConfig API#306

Merged
meling merged 2 commits intomasterfrom
feature/299/update-all-callers
Mar 25, 2026
Merged

refactor: update all callers to use new NewConfig API#306
meling merged 2 commits intomasterfrom
feature/299/update-all-callers

Conversation

@meling
Copy link
Member

@meling meling commented Mar 25, 2026

Summary

Updates all internal callers, generated benchmark/example code, and tests to use the new NewConfig(nodes, opts...) API introduced in #298.
This removes all direct use of the old two-step NewManager + NewConfiguration pattern throughout the codebase.

Changes

  • Update benchmark/ generated code to use NewConfig
  • Update examples/ to use NewConfig
  • Update generated *_gorums.pb.go files
  • Update internal test helpers

Related

Part of #294
Closes #299

@deepsource-io
Copy link
Contributor

deepsource-io bot commented Mar 25, 2026

DeepSource Code Review

We reviewed changes in f03076b...8a55f2c 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 1:50p.m. Review ↗
Shell Mar 25, 2026 1:50p.m. Review ↗

@meling meling force-pushed the feature/298/simplify-newconfig-signature branch 2 times, most recently from cad6f15 to 822cab8 Compare March 25, 2026 11:37
Base automatically changed from feature/298/simplify-newconfig-signature to master March 25, 2026 13:44
meling added 2 commits March 25, 2026 14:47
Changes NewConfig(opts ...Option) to NewConfig(nodes NodeListOption,
opts ...DialOption), making the required NodeListOption explicit and
aligning with standard Go API conventions (required args first).

Additional changes:
- Add Configuration.Close() error for closing connections without
  accessing the internal Manager directly.
- Add unexported Configuration.mgr() used by Extend and Add internally.
- Deprecate Configuration.Manager() in favor of Configuration.Close().
- Deprecate NewConfiguration; callers should use NewConfig instead.
- Remove Manager, NewManager, NewConfiguration from generated code
  template; update NewConfig wrapper to the new signature.
- Remove Manager from the reservedIdents list.

NOTE: Existing generated files still call the old gorums.NewConfig
signature and will fail to compile until regenerated in commit 6.

Closes #298. Related to #294.
Update non-generated callers to use the new NewConfig(nodes, opts...) API:

- config.go: close manager on error in NewConfig to prevent resource leak
- system.go: use cfg (Configuration) as io.Closer directly instead of cfg.Manager()
- system_test.go: use cfg.Close() instead of cfg.Manager().Close()
- testopts.go: rename existingMgr to existingCfg, update WithManager to accept
  Configuration instead of *Manager; update shouldSkipGoleak and type switch
- testing_bufconn.go: use existingCfg.mgr() in getOrCreateManager
- testing_integration.go: use existingCfg.mgr() in getOrCreateManager
- config_test.go: replace NewManager+NewConfiguration with NewConfig; remove
  redundant mgr.Size() checks
- server_test.go: use NewConfig in TestTCPReconnection
- internal/tests/config/config_test.go: use WithManager(t, c1) instead of
  WithManager(t, c1.Manager())

Update template static code to remove Manager/NewManager/NewConfiguration wrappers
and update NewConfig signature in generated code:

- cmd/protoc-gen-gorums/dev/aliases.go: remove Manager type alias, NewManager and
  NewConfiguration functions; update NewConfig to take (nodes NodeListOption,
  opts ...DialOption)
- cmd/protoc-gen-gorums/gengorums/template_static.go: regenerate from aliases.go
@meling meling force-pushed the feature/299/update-all-callers branch from 50924a6 to 8a55f2c Compare March 25, 2026 13:49
@meling meling requested a review from Copilot March 25, 2026 13:50
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

Updates the codebase to consistently use the new NewConfig(nodes, dialOptions...) constructor API (introduced in #298), removing remaining internal/test call sites that relied on the older NewManager + NewConfiguration pattern.

Changes:

  • Refactor tests and helpers to construct configurations via NewConfig(...) and clean up via cfg.Close().
  • Update test option plumbing to reuse an existing configuration’s underlying manager instead of passing a *Manager.
  • Adjust system lifecycle management to register Configuration itself as a closer (rather than cfg.Manager()).

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
config.go Updates NewConfig construction flow and ensures manager is closed on constructor error.
config_test.go Migrates configuration-construction tests to NewConfig and updates teardown accordingly.
server_test.go Refactors reconnection test to use NewConfig and closes the configuration in cleanup.
system.go Registers the outbound Configuration itself as an io.Closer for system shutdown.
system_test.go Updates cleanup to close configuration via cfg.Close() instead of cfg.Manager().Close().
testopts.go Changes WithManager test option to accept a Configuration for manager reuse.
testing_integration.go Reuses manager from an existing configuration in integration build setup.
testing_bufconn.go Reuses manager from an existing configuration in bufconn build setup.
internal/tests/config/config_test.go Updates internal generated tests to reuse the manager via WithManager(t, cfg).
cmd/protoc-gen-gorums/dev/aliases.go Aligns generated dev aliases wrapper NewConfig docs/signature usage with new API.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@meling meling merged commit b06220f into master Mar 25, 2026
9 checks passed
@meling meling deleted the feature/299/update-all-callers branch March 25, 2026 14:00
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.

refactor: update all callers to new NewConfig signature

2 participants