Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix anti-pattern naming problem in config.ClusterConfig #14629

Merged
merged 1 commit into from
Oct 26, 2022

Conversation

clement2026
Copy link
Contributor

This PR tries to fix the anti-pattern naming problem(see #14389), such as DisableStrictReconfigCheck(written by me🤣).

As far as I see, at least 4 structs have this problem:

  1. ctlCtx
  2. config.ClusterConfig
  3. e2e.EtcdProcessClusterConfig
  4. integration.ClusterConfig

This PR only tries to fix (2)config.ClusterConfig.
(3)e2e.EtcdProcessClusterConfig and (4)integration.ClusterConfig will be fixed after this PR.

This PR changed (2)config.ClusterConfig with the Functional Options Pattern. I’m not sure if this is a proper solution. Please take a look and give some suggestions.

@clement2026 clement2026 force-pushed the fix-anti-pattern-naming branch from b4c332a to 08284c5 Compare October 26, 2022 07:47
@clement2026 clement2026 marked this pull request as ready for review October 26, 2022 08:18
Copy link
Member

@serathius serathius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using options looks like a nice improvement. Thanks!


func NewClusterConfig(clusterSize int, opts ...ClusterOption) ClusterConfig {
c := defaultClusterConfig()
c.ClusterSize = clusterSize
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment: can we add a ClusterOption interface for ClusterSize as well? The benefit is that we don't need to provide a clusterSize if we use the default value.

It isn't a big deal. Feel free to think/discuss this in a separate PR.

Copy link
Member

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thank you @clarkfw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants