Repository navigation
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>
08fe6ec to
060e312
Compare
|
+1 from a Node consumer of Avro-schema'd topics. This unblocks schema evolution for us. Avro binary is positional, so a consumer can only read a message written with a newer or older (compatible) schema version if it knows the writer's schema and resolves it against its own, e.g. with avsc's With A |
|
Could we follow the C++ naming convention? Such as |
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