You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/07/31 07:57:58 UTC

[GitHub] [rocketmq-schema-registry] humkum commented on pull request #16: add avro schema serializer and deserializer

humkum commented on PR #16:
URL: https://github.com/apache/rocketmq-schema-registry/pull/16#issuecomment-1200370665

   > I have an idea about design of schema serializer/deserializer
   > 
   > What's exposed to users is `SchemaWrapper`, which includes `Map<String/*SchemaType*/, Serializer>` and `Map<String/*SchemaType*/, Deserializer>`(such as <AVRO, AvroSerializer>, or use Factory...). Then the user doesn't need to know the schema type (avro/json/thrift....) and just leave the serializer work to `SchemaWrapper`. In `SchemaWrapper`, after getting schema from registry, we can know the type of schema, then we can decide what kind of serializer to use.
   > 
   > The pseudo code as follows.
   > 
   > ```
   > public class SchemaWrapper {
   > 
   >     private final SchemaRegistryClient schemaRegistryClient;
   > 
   >     private Map<String/*schema type*/, Serializer> serializerMap;
   >     
   >     <T> byte[] serialize(T data, String topic) throws Exception{
   >         GetSchemaResponse response = schemaRegistryClient.getSchemaBySubject(topic);
   >         Serializer serializer = serializerMap.get(response.getType);
   >         return serializer.serialize(data, response.getIdl());
   >     }
   > 
   >     
   >     <T> T deserialize(byte[] data, String topic) {
   >         
   >     }
   > }
   > ```
   > 
   > @humkum @ferrirW What do you think about this design?
   
   good idea!


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org