RobertIndie commented on issue #1296: URL: https://github.com/apache/pulsar-client-go/issues/1296#issuecomment-2443790654
> I expected JsonSchema to function similarly to AvroSchema, since its very close to it - schema definition is Avro for both, only the type in SchemaInfo is what differs, and how message validation works apparently. Might be a naive view since I haven't looked at how they differ in the internals of Pulsar. When the client encodes the Avro message, the Avro encoder automatically validates the schema. However, JSON schema encoding works differently. We do not pass the schema definition to the encoder. Instead, we encode from any object type to JSON bytes. The JSON encoder does not perform any validation. This's same for both the GO and Java client. > Shouldn't the client library ensure that messages sent with a Schema Producer adhere to its schema? [This](https://github.com/fsprojects/pulsar-client-dotnet/) .NET library returns a typed producer which can't send other type of messages through it, for example. > My impression of the schema validation feature of Pulsar is that it should bring in some guardrails to get some contract between producers and consumers. For client SDKs such as .Net and Java, they can use generics class feature to restrict the type of messages sent or received by the producer or consumer. However, the Go producer and consumer do not use generics. In fact, they are more similar to the Java client's Producer<byte[]>. Since Go introduced struct generics from go 1.18, it might be worthwhile to implement a similar feature for the Go producer and consumer. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
