Closed ramonpin closed 2 years ago
Hello,
While ago I changed the interface for consumers but I forgot to update the specs. You can read the motivation here:
https://github.com/silviucpp/erlkaf/blob/master/CHANGELOG.md#v200
In erlkaf 1.x the topics were under : [<<"topic1">>, <<"topic2">>]
format.
Now in 2.x:
[
{<<"topic1">>, [
{callback_module, module_topic1},
{callback_args, []}
]},
{<<"topic2">>, [
{callback_module, module_topic2},
{callback_args, []}
]}
So it's a tuple, where the first element is the topic name (a binary) and the second is a list of callback settings.
I think the correct signature is now to add in the erlkaf.hrl a new type:
-type callback_options() :: callback_module|callback_args.
And then to define it as :
[{binary(), [callback_options()]}]
What do you think ? Also if you agree I apreciate if you can send a PR for this.
I will prepare a PR. My hesitation was about me not knowing how to do It properly. I am just a beginner with spec declarations on erlang.
I believe your proposed type will work.
Thanks for PR !
The contract for
create_consumer_group
function says:It seems that we expect
Topics
to be a[binary()]
but later in the code there is the following validation:That seems to force
Topics
to be a list of pairs{binary(), [{callback_module, atom()}]}
or similar.Dialyzer says the contract is broken for valid
Topics
parameter.I believe we only need to properly define the spec for the
Topics
parameter atcreate_consumer_group
but don't really know which is the proper type for it.