Jun Rao created KAFKA-18177:
-------------------------------
Summary: generate better helper code to support changing keys in
request/response schema
Key: KAFKA-18177
URL: https://issues.apache.org/jira/browse/KAFKA-18177
Project: Kafka
Issue Type: Improvement
Reporter: Jun Rao
In [https://github.com/apache/kafka/pull/15968,] we are changing the key for a
collection in ProduceRequest from name to topicId.
{code:java}
{ "name": "Name", "type": "string", "versions": "0-11", "entityType":
"topicName", "mapKey": true, "ignorable": true,
"about": "The topic name." },
{ "name": "TopicId", "type": "uuid", "versions": "12+", "mapKey": true,
"ignorable": true, "about": "The unique topic ID" },{code}
The generated code TopicProduceDataCollection has the following helper method
that uses both name and topicId.
{code:java}
public static class TopicProduceDataCollection extends
ImplicitLinkedHashMultiCollection<TopicProduceData> {
...
public TopicProduceData find(String name, Uuid topicId) {
TopicProduceData _key = new TopicProduceData();
_key.setName(name);
_key.setTopicId(topicId);
return find(_key);
}{code}
If we don't know which version of the request to use, we can use this method by
passing in both name and topicId. However, in some cases (especially during
testing), we know the version (often the latest version) of the request to use.
In this case, it's inconvenient to use find("", topicId). It's better if we
could generate a helper method find(Uuid topicId) that sets name to the default
value under the cover.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)