improvement: allow setting a Message `Key` as `AddValue` parameter
It is possible to set the Key for a message on the message and then pass it to AddMessage but there is no way to set it with AddValue.
This way you offer two different APIs to do the same but one of them is not supporting all options/features.
Maybe there should be only one simple to use API
I would prefer the AddValue API. I think the user should not know about the Message class and there are just a few fields to set. And using the message class on the outside means to create and destroy a object just to call it (because you need a internal copy until it is delivered) -> overhead.
I fully agree. This one needs to go away. Probably better to just have AddMessage!?
I don't like the AddMessage method signature.
- you have to create a
Message, call some methods to set all attributes. - depending on the use case you have to create a
MessageSetthen. - then you pass the object to the
AddMessagemethod which makes a deep copy of it. - then you have to clean up the
MessageSetand theMessage - after that the lib will clean up the same information again.
this sounds like overhead. calling much more methods then needed. and doing some memory allocations we don't need (2*
MessageSetand theMessages). I think it would be better to improve theAddValuemethod and maybe rename it toAddMessage. We know all components of a Message and they are just a few:
- topic (may be given by config on produce/producer level)
- partition (may be given by config on produce/producer level)
- key (optional)
- value the rest is calculated or can be set by config