Skip to content

refactor: simplify NewConfig signature; remove NewConfiguration and Manager alias #298

@meling

Description

@meling

Part of #294.

Summary

Simplify the NewConfig signature from a variadic ...Option to an explicit (nodes NodeListOption, dialOptions ...DialOption), remove the now-unused NewConfiguration function and Configuration.Manager() method (replaced by the unexported mgr()), add Configuration.Close() as a convenience, and strip the Manager alias and NewManager / NewConfiguration forwarding functions from the generated static code.

Motivation

  • The old variadic ...Option allowed mixing ServerOption, NodeListOption, and ManagerOption in one call, which required runtime type-switching and produced confusing errors.
  • NewConfiguration(mgr, opt) required callers to construct a Manager explicitly, which is now internal.
  • The Manager alias in generated code leaked the implementation detail into every generated package.
  • Users can still continue create sub-configurations using Difference and Remove or Extend and existing configuration with more nodes (and use the same underlying outboundManager as the original configuration.)

Changes

  • config.go:
    • Change NewConfig(opts ...Option) to NewConfig(nodes NodeListOption, dialOptions ...DialOption)
    • Remove NewConfiguration
    • Rename Configuration.Manager() to Configuration.mgr() (unexported)
    • Add Configuration.Close() error
    • Update Extend and Add to call c.mgr()
  • cmd/protoc-gen-gorums/dev/aliases.go:
    • Remove Manager alias, NewManager, NewConfiguration forwarding functions
    • Update NewConfig forwarding signature
  • cmd/protoc-gen-gorums/gengorums/template_static.go:
    • Mirror the same changes in the static code template
    • Remove Manager from reservedIdents

Files Changed

config.go, cmd/protoc-gen-gorums/dev/aliases.go, cmd/protoc-gen-gorums/gengorums/template_static.go

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions