Conversation
Add Message.getSchemaVersion(), which returns the version of the schema the producer used to serialize the message, or null when the message carries no schema version. It wraps the C++ client's hasSchemaVersion() and getLongSchemaVersion(). Consumers of Avro or JSON topics need the writer schema version to decode messages produced with an older, compatible schema. Master Issue: apache#362 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Master Issue: #362
This is the first of two parts. A follow-up PR will expose
Client.getSchemaInfo(topic, version)so a consumer can fetch the writer schema for a given version.Motivation
A consumer of an Avro or JSON topic needs the writer schema version of each message to decode messages produced with an older, compatible schema. The Java client exposes this through
Message.getSchemaVersion()and the Python client throughMessage.schema_version()/int_schema_version(). The bundled C++ client already providesMessage::hasSchemaVersion()andMessage::getLongSchemaVersion(), but the Node client does not expose them.Modifications
src/Message.h,src/Message.cc: addMessage.getSchemaVersion(). It returns the value ofgetLongSchemaVersion()as a number, ornullwhenhasSchemaVersion()is false.index.d.ts: declaregetSchemaVersion(): number | nullonMessage.tstest.ts: add a typing check for the new method.tests/end_to_end.test.js: add thegetSchemaVersiontest.Verifying this change
This change added tests and can be verified as follows:
getSchemaVersion. It:0;1;null. With no schema, the broker registers no schema for the topic and the message metadata carries no schema version, sohasSchemaVersion()is false.Locally, the test fails if
getSchemaVersion()returns a constant.Documentation
doc-requireddoc-not-needed(New
Messagegetter, documented inindex.d.ts, which generates the API reference. The client feature matrix has no row for this.)docdoc-complete🤖 Generated with Claude Code