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
Part of #294.
Summary
Simplify the
NewConfigsignature from a variadic...Optionto an explicit(nodes NodeListOption, dialOptions ...DialOption), remove the now-unusedNewConfigurationfunction andConfiguration.Manager()method (replaced by the unexportedmgr()), addConfiguration.Close()as a convenience, and strip theManageralias andNewManager/NewConfigurationforwarding functions from the generated static code.Motivation
...Optionallowed mixingServerOption,NodeListOption, andManagerOptionin one call, which required runtime type-switching and produced confusing errors.NewConfiguration(mgr, opt)required callers to construct aManagerexplicitly, which is now internal.Manageralias in generated code leaked the implementation detail into every generated package.DifferenceandRemoveorExtendand existing configuration with more nodes (and use the same underlyingoutboundManageras the original configuration.)Changes
config.go:NewConfig(opts ...Option)toNewConfig(nodes NodeListOption, dialOptions ...DialOption)NewConfigurationConfiguration.Manager()toConfiguration.mgr()(unexported)Configuration.Close() errorExtendandAddto callc.mgr()cmd/protoc-gen-gorums/dev/aliases.go:Manageralias,NewManager,NewConfigurationforwarding functionsNewConfigforwarding signaturecmd/protoc-gen-gorums/gengorums/template_static.go:ManagerfromreservedIdentsFiles Changed
config.go,cmd/protoc-gen-gorums/dev/aliases.go,cmd/protoc-gen-gorums/gengorums/template_static.go