Closed dseapy closed 3 years ago
Thanks for the PR, could you give some use cases for this functionality?
Adding to https://github.com/riferrei/srclient/pull/56#issuecomment-974810041, the goal here is to be able to validate json messages when dealing with existing topics that have a JSON schema type registered in the schema registry. For instance, if a topic has a JSON schema registered, then having argo dataflow make sure that anything written to the topic by the user is compliant with the schema.
The json schema would need to be compiled at most once per schema for performance. The easiest way I could think of was treat it similar to AVRO codec (reference to one in the Schema struct, initializing when/if requested), but I realize this does introduce another dependency to the repo.
An alternative to this approach that I have considered would be to cache the compiled json schema outside of srclient and look that up when interacting with JSON topics. If adding a compiled jsonschema to the Schema struct isn't desired, then this alternative should work, it just wouldn't be quite as elegant on the caller side (ie. argo dataflow).
It wouldn't seem fair that we have built in codec for Avro but not for JSON. But there are some conflicts, please resolve them and I'll merge.
Signed-off-by: David Seapy dseapy@gmail.com