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

Use dedicated type for representing the Group #91

Open
jorgebay opened this issue Nov 7, 2022 · 1 comment
Open

Use dedicated type for representing the Group #91

jorgebay opened this issue Nov 7, 2022 · 1 comment
Labels
code quality How an existing feature is implemented / refactor required for simplification enhancement New feature or request good first issue Good for newcomers

Comments

@jorgebay
Copy link
Contributor

jorgebay commented Nov 7, 2022

We should use a type for representing the group name that way we make sure that it doesn't get mixed with other string parameters.

For example:

type Group string

and then, use the Group type for method signatures:

type OffsetState interface {
	Initializer
	fmt.Stringer

	// Here: Use Group instead of string
	Get(group Group, ...) offset *Offset

	// Use Group instead of string
	GetAllWithDefaults(group Group, t...) []Offset

	// Use Group instead of string
	Set(group Group, ...) bool
	// ...
}
@jorgebay jorgebay added enhancement New feature or request good first issue Good for newcomers code quality How an existing feature is implemented / refactor required for simplification labels Nov 7, 2022
@jorgebay
Copy link
Contributor Author

We use mockery for test mocks. Changing the signature of interfaces will require the mocks to be updated, for example:

mockery -r --case=snake \
  --output=./internal/test/interbroker/mocks --name=Gossiper

mockery -r --case=snake \
  --output=./internal/test/types/mocks --name=OffsetState

mockery -r --case=snake \
  --output=./internal/test/data/mocks --name=Datalog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality How an existing feature is implemented / refactor required for simplification enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant