Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:brod.create_topics topic config? #469

Open
jamespeterschinner opened this issue Aug 23, 2021 · 5 comments
Open

:brod.create_topics topic config? #469

jamespeterschinner opened this issue Aug 23, 2021 · 5 comments

Comments

@jamespeterschinner
Copy link

Hey folks,

I've have a use case for the create_topics and delete_topics in my test cases.

#348

I'm using brod 3.16 in an Elixir context, and running the above example in the shell gives me an error:

topic_config = [
  %{
    config_entries: [],
    num_partitions: 2,
    replica_assignment: [],
    replication_factor: 1,
    topic: "test_create_topic"
  }
]
:brod.create_topics([{'localhost', 9092}], topic_config, %{})
:brod.delete_topics([{'localhost', 9092}], ["test_create_topic"], 1_000)
iex(10)> :brod.create_topics([{'localhost', 9092}], topic_config, %{})
** (ErlangError) Erlang error: {:field_missing, [stack: [{:create_topics, 0}, :topics, :name], input: %{config_entries: [], num_partitions: 2, replica_assignment: [], replication_factor: 1, topic: "test_create_topic"}]}

Thanks for the great work in creating brod 👍

@v0idpwn
Copy link
Contributor

v0idpwn commented Aug 23, 2021

Hey!

Based in the errors, I managed to get it working with:

[
  %{
    assignments: [],
    configs: [],
    name: "sample",
    num_partitions: 1,
    replication_factor: 1
  }
]

Here are the schemas for this request: https://github.com/kafka4beam/kafka_protocol/blob/9ee00f2efa97df23c13d12a48196bed11e183f41/src/kpro_schema.erl#L582

Which makes me think there is some documentation error, as any of the schemas use the documented names.

Perhaps someone from the team knows better? If it is misdocumented, I can send a PR

@zmstone
Copy link
Contributor

zmstone commented Aug 23, 2021

Hi.

topic_config = [
  %{
    config_entries: [],
    num_partitions: 2,
    replica_assignment: [],
    replication_factor: 1,
    topic: "test_create_topic"
  }
]

this seem to be the old layout which should work with brod 3.15
brod 3.16 has kafka_protocol upgraded to 4.0,
there were quite some non-backward compatible schema changes.

I'm not sure if this implicit API contract is documented anywhere.

@jamespeterschinner
Copy link
Author

Thanks for the quick reply folks!

@v0idpwn
Copy link
Contributor

v0idpwn commented Sep 3, 2021

I'm a bit confused here: should we update these readme example? If yes, I can submit a PR.

@zmstone
Copy link
Contributor

zmstone commented Sep 14, 2021

yes. we should update the readme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants