polarstreams / polar

Lightweight & elastic kubernetes-native event streaming system
GNU Affero General Public License v3.0
204 stars 15 forks source link

Use dedicated type for representing the Group #91

Open jorgebay opened 1 year ago

jorgebay commented 1 year ago

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 commented 1 year ago

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