In this PR I've added the support to the latest kafka schema 3.7.0.
The PR is split into 2 commits, the first is only code-generator related code, and the latter is the generated code.
Some extra logic was added to handle new schema fields and usages, in particular:
tag field was used with a string instead of a number (on the java side it's always an integer) (BrokerHeartbeatRequest.json)
handled by modifying directly the parsed json, converting any tag string type into a number
some dependencies were added in reverse order in the common section of a structure (AddPartitionsToTxnResponse.json)
I've split logical resolution from writing code and iteratively resolve types until they don't change anymore. The code generated within a loop after all types were resolved.
latestVersionUnstable was introduced, and it's used when only one version exposed
I felt like we shouldn't generate code from unstable schema, so in case this flag is enabled, the last version is stripped. When no versions remains both request and relative response are removed. (ConsumerGroupDescribeRequest.json)
deprecated_versions was introduced
Exposed the versions in a constant within the Message
an optional field structure was used for the first time
I've added a OptionStruct with encoding/decoding (one signed byte 1/-1, when present/not present)
Minor refactoring was also done:
To avoid defaults being applied multiple times across the codebase, the structure avoids Option<> whenever possible. To keep the parsing check working, the assertion was changed into assert_json_include, so we can assert we are parsing every field from the schema.
cargo fmt executed at the end of the generation, to keep the output as consistent as possible.
In this PR I've added the support to the latest kafka schema 3.7.0. The PR is split into 2 commits, the first is only code-generator related code, and the latter is the generated code. Some extra logic was added to handle new schema fields and usages, in particular:
BrokerHeartbeatRequest.json
)AddPartitionsToTxnResponse.json
)latestVersionUnstable
was introduced, and it's used when only one version exposedConsumerGroupDescribeRequest.json
)deprecated_versions
was introducedMessage
OptionStruct
with encoding/decoding (one signed byte 1/-1, when present/not present)Minor refactoring was also done:
Option<>
whenever possible. To keep the parsing check working, the assertion was changed intoassert_json_include
, so we can assert we are parsing every field from the schema.cargo fmt
executed at the end of the generation, to keep the output as consistent as possible.