Closed yaziine closed 5 years ago
I don't think it's true that it's not usable - the RetryInterval already defaults, and both Logging and Metrics are optional.
There are optional indeed but if I want to use the Logger for example before calling the Handle
method (which calls the setup
one). How can I do?
The use case is for kafka-go
, I need the Logger
before any calls to Handle
.
So you simply initialise the Consumer with the Logger:
c := &Consumer{Logger: myLogger}
.. no?
Yes you are right, I am always wondering when should I use a constructor or not.
I think that we should have a constructor for the
Consumer
type because its zero value is not usable.For example, if I create a consumer like that:
c
is not usable because I need to have some fields to be initialized (think of the Logger for example).Two proposals:
setup
method and don't call it from theHandle
anymorefunc New(//maybe some params) *Consumer {...}
) and remove thesetup
method