heetch / felice

Felice is a nascent, opinionated Kafka library for Go, in Go
MIT License
20 stars 1 forks source link

Rework Consumer API #44

Closed yaziine closed 5 years ago

yaziine commented 5 years ago

As @rogpeppe duly noticed, the actual Consumer's API can lead to several mistakes if it is not configured properly.

The idea is to add a constructor for the Consumer which holds a ready to use configuration, something like the following:

package consumer

func New(cfg *Config) *Consumer {
...
}

This is a big breaking changes but as we are still in v0.x.x, it is still the time to break the API.

What do you think guys @rogpeppe @tealeg @asdine?

rogpeppe commented 5 years ago

I think this would be worth doing, although I think I'd make this the signature:

func New(cfg Config) (*Consumer, error)

That way we're free to return an error when the configuration is invalid and we lose the edge case of having a nil config.