Skip to content

refactor: simplify NewConfig signature, add Configuration.Close#305

Merged
meling merged 5 commits intomasterfrom
feature/298/simplify-newconfig-signature
Mar 25, 2026
Merged

refactor: simplify NewConfig signature, add Configuration.Close#305
meling merged 5 commits intomasterfrom
feature/298/simplify-newconfig-signature

Conversation

@meling
Copy link
Member

@meling meling commented Mar 25, 2026

Summary

Previously, creating a configuration required two separate steps: create a *Manager, then call NewConfiguration(mgr, nodes).
This simplifies the API to a single constructor:

cfg, err := gorums.NewConfig(
    gorums.WithNodeList(addrs),
    gorums.WithDialOptions(grpc.WithTransportCredentials(insecure.NewCredentials())),
)

The manager is created internally and owned by the configuration.
Configuration.Close() is added to close all node connections and release resources.

Changes

  • NewConfig(nodes NodeListOption, opts ...DialOption) (Configuration, error) — new simplified constructor
  • Configuration.Close() error — closes the owning manager and all node connections
  • Mark old two-step pattern deprecated in preparation for removal

Related

Part of #294
Closes #298

@deepsource-io
Copy link
Contributor

deepsource-io bot commented Mar 25, 2026

DeepSource Code Review

We reviewed changes in 5a184a6...59da6b1 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:38p.m. Review ↗
Shell Mar 25, 2026 1:38p.m. Review ↗

@meling meling force-pushed the feature/297/with-server-remove-server-newconfig branch from 7a8369c to dfa23d4 Compare March 25, 2026 11:09
Base automatically changed from feature/297/with-server-remove-server-newconfig to master March 25, 2026 11:26
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.
@meling meling force-pushed the feature/298/simplify-newconfig-signature branch from d5148e3 to cad6f15 Compare March 25, 2026 11:27
@meling meling requested a review from Copilot March 25, 2026 11:28
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.

Copilot wasn't able to review any files in this pull request.


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

@meling meling force-pushed the feature/298/simplify-newconfig-signature branch from cad6f15 to 822cab8 Compare March 25, 2026 11:37
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

Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.


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

meling added 2 commits March 25, 2026 13:34
Previously, WithMetadata replaced o.metadata with the caller-supplied
value. This clobbered node-id metadata set by withRequestHandler (via
WithServer) when WithServer was applied before a user-provided
WithMetadata option, breaking reverse-direction routing.

Fix by using metadata.Join so that WithMetadata accumulates metadata
instead of replacing it, consistent with the existing PerNodeMD and
withRequestHandler patterns.

Add TestWithMetadataJoinsInsteadOfOverwrites to cover the ordering case.
@meling meling merged commit f03076b into master Mar 25, 2026
5 checks passed
@meling meling deleted the feature/298/simplify-newconfig-signature branch March 25, 2026 13:44
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: simplify NewConfig signature; remove NewConfiguration and Manager alias

2 participants